-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestTimer.cs
More file actions
29 lines (23 loc) · 753 Bytes
/
Copy pathTestTimer.cs
File metadata and controls
29 lines (23 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using HardCodeDev.UltraTimerWindows.Runtime;
using UnityEngine;
public sealed class TestTimer : MonoBehaviour
{
private UltraTimerWindows _timer;
private void Start() => _timer = new();
private void Update()
{
using (_timer.Measure("Test")) HeavyMethod();
Debug.Log($"Last elapsed: {_timer.State.lastElapsedMs} ms, total elapsed: {_timer.State.totalElapsedMs} ms, average: {_timer.State.averageMs} ms, called: {_timer.State.countOfCalling} times");
}
private void HeavyMethod()
{
for (int i = 0; i < 100000; i++)
{
float x = Mathf.Sqrt(i);
}
}
/// <summary>
/// IMPORTANT!
/// </summary>
private void OnDestroy() => _timer?.Dispose();
}