https://github.com/xjine/unity_stopwatch
Utility to measure performance of small action/function or continuous codes.
https://github.com/xjine/unity_stopwatch
assets unity
Last synced: about 1 month ago
JSON representation
Utility to measure performance of small action/function or continuous codes.
- Host: GitHub
- URL: https://github.com/xjine/unity_stopwatch
- Owner: XJINE
- License: bsd-3-clause
- Created: 2018-09-20T10:00:20.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2022-06-24T07:15:00.000Z (about 4 years ago)
- Last Synced: 2025-07-05T06:38:31.040Z (12 months ago)
- Topics: assets, unity
- Language: C#
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity_Stopwatch
Utility to measure performance of small action/function or continuous codes.
NOTE:
This is not depends on Unity. Main codes is able to works on native C#.
## Importing
You can use Package Manager or import it directly.
```
https://github.com/XJINE/Unity_Stopwatch.git?path=Assets/Packages/Stopwatch
```
## How to Use
``MeasureAction`` method is the easiest way to measure action.
Pass an action and the iteration count, it will returns the time of the action.
```csharp
Debug.Log(Stopwatch.MeasureAction(delegate ()
{
var transform = base.transform;
},
loopCount).TotalMilliseconds);
```
If you pass ``true`` as third argument, the result will shows average time.
You can use 3 methods to get more strict time. ``Start``, ``Stop`` and ``Restart``.
```csharp
Stopwatch.Restart();
for (int i = 0; i < loopCount; i++)
{
var transform = base.transform;
}
Stopwatch.Stop();
Debug.Log(Stopwatch.Ellapsed.TotalMilliseconds);
```