-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
Performance profiler
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using UniRx; | ||
|
||
namespace Hatbor.PerformanceProfiler | ||
{ | ||
public sealed class FrameRateProfilerRecorder : IProfilerRecorder | ||
{ | ||
readonly ReactiveProperty<string> text = new(); | ||
IReadOnlyReactiveProperty<string> IProfilerRecorder.Text => text; | ||
|
||
int count; | ||
float time; | ||
|
||
void IProfilerRecorder.Tick(float t) | ||
{ | ||
count++; | ||
time += t; | ||
if (!(time >= 1f)) return; | ||
var frameRate = count / time; | ||
text.Value = $"Frame Rate: {frameRate:F2}/s"; | ||
time = 0f; | ||
count = 0; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "Hatbor.PerformanceProfiler", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:560b04d1a97f54a4e82edc0cbbb69285", | ||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using UniRx; | ||
|
||
namespace Hatbor.PerformanceProfiler | ||
{ | ||
public interface IProfilerRecorder | ||
{ | ||
IReadOnlyReactiveProperty<string> Text { get; } | ||
|
||
public void Tick(float t); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using VContainer; | ||
using VContainer.Unity; | ||
|
||
namespace Hatbor.PerformanceProfiler | ||
{ | ||
public sealed class PerformanceProfilerTicker : ITickable | ||
{ | ||
readonly IEnumerable<IProfilerRecorder> profilerRecorders; | ||
|
||
[Inject] | ||
public PerformanceProfilerTicker(IEnumerable<IProfilerRecorder> profilerRecorders) | ||
{ | ||
this.profilerRecorders = profilerRecorders; | ||
} | ||
|
||
void ITickable.Tick() | ||
{ | ||
foreach (var recorder in profilerRecorders) | ||
{ | ||
recorder.Tick(Time.unscaledDeltaTime); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using UniRx; | ||
|
||
namespace Hatbor.PerformanceProfiler | ||
{ | ||
public sealed class VmcServerProfilerRecorder : IProfilerRecorder | ||
{ | ||
readonly ReactiveProperty<string> text = new(); | ||
IReadOnlyReactiveProperty<string> IProfilerRecorder.Text => text; | ||
|
||
int count; | ||
float time; | ||
|
||
void IProfilerRecorder.Tick(float t) | ||
{ | ||
time += t; | ||
if (!(time >= 1f)) return; | ||
var frameRate = count / time; | ||
text.Value = $"VMC Received OK: {frameRate:F2}/s"; | ||
time = 0f; | ||
count = 0; | ||
} | ||
|
||
public void IncrementCount() | ||
{ | ||
count++; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using Hatbor.PerformanceProfiler; | ||
using UniRx; | ||
using UnityEngine.UIElements; | ||
|
||
namespace Hatbor.UI | ||
{ | ||
public sealed class PerformanceGroup : VisualElement | ||
{ | ||
readonly IFileBrowser fileBrowser; | ||
|
||
readonly Label label; | ||
readonly VisualElement container; | ||
|
||
public PerformanceGroup() | ||
{ | ||
|
||
label = new Label(); | ||
hierarchy.Add(label); | ||
container = new VisualElement(); | ||
hierarchy.Add(container); | ||
} | ||
|
||
public IDisposable Bind(IProfilerRecorder recorder) | ||
{ | ||
var disposables = new CompositeDisposable(); | ||
recorder.Text | ||
.Subscribe(t => label.text = t) | ||
.AddTo(disposables); | ||
return disposables; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.