Skip to content

Commit b08e3b2

Browse files
Add README and update package.json
1 parent c78961a commit b08e3b2

File tree

5 files changed

+132
-5
lines changed

5 files changed

+132
-5
lines changed
File renamed without changes.

README.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,131 @@
1-
# UltraTimerWindows
1+
![Unity](https://img.shields.io/badge/Unity-unity?logo=Unity&color=%23000000)
2+
![C#](https://img.shields.io/badge/C%23-%23512BD4?logo=.NET)
3+
![C](https://img.shields.io/badge/C-%23A8B9CC?logo=C&logoColor=%23ffffff)
4+
![License](https://img.shields.io/github/license/HardCodeDev777/UltraTimerWindows?color=%2305991d)
5+
![Last commit](https://img.shields.io/github/last-commit/HardCodeDev777/UltraTimerWindows?color=%2305991d)
6+
![Tag](https://img.shields.io/github/v/tag/HardCodeDev777/UltraTimerWindowsh)
7+
![Top lang](https://img.shields.io/github/languages/top/HardCodeDev777/UltraTimerWindows)
8+
 
29

10+
11+
# 🔥 UltraTimerWindows
12+
13+
---
14+
15+
## 🚀 Overview
16+
17+
**UltraTimerWindows** is a zero-allocation, native high-resolution timer for Unity, built on top of Windows ``QueryPerformanceCounter``.
18+
Suitable for micro-benchmarks and hot-path measurements. Provides sub-millisecond and microsecond-level timing precision.
19+
20+
The overhead of the timer itself is negligible compared to typical Unity workloads.
21+
22+
---
23+
24+
## ✨ Features
25+
26+
-**High-resolution native timing in pure C** (WinAPI `QueryPerformanceCounter`)
27+
- 🧹 **Zero GC allocations during measurement**
28+
- 🔒 **Deterministic and low-overhead**
29+
- 🔥 **Suitable for micro-benchmarks and hot-path measurements**
30+
- ⚙️ **IL2CPP & Mono compatible**
31+
- 🧩 **Scoped measurement via `using`**
32+
- 🎞️ **Profile sampling for each scope**
33+
- 🔬 **Independent from Unity Profiler**
34+
35+
36+
---
37+
38+
## 📦 Installation
39+
40+
Via UPM: `https://github.com/HardCodeDev777/UltraTimerWindows.git?path=Unity`
41+
42+
---
43+
44+
## 💻 Usage
45+
46+
**UltraTimerWindows** provides very elegant and simple API:
47+
48+
---
49+
50+
### 💡 Basic example of usage
51+
52+
```csharp
53+
using UnityEngine;
54+
// Namespace
55+
using HardCodeDev.UltraTimerWindows.Runtime;
56+
57+
public class TestTimer : MonoBehaviour
58+
{
59+
// Timer instance
60+
private UltraTimerWindows _timer;
61+
62+
private void Start() => _timer = new();
63+
64+
private void Update()
65+
{
66+
using (_timer.Measure())
67+
{
68+
// Here you can call any methods you want to measure
69+
HeavyMethod();
70+
}
71+
72+
// See results in the console
73+
Debug.Log($"Last elapsed: {_timer.State.lastElapsedMs} ms, " +
74+
$"total elapsed: {_timer.State.totalElapsedMs} ms, " +
75+
$"average: {_timer.State.averageMs} ms, " +
76+
$"called: {_timer.State.countOfCalling} times");
77+
}
78+
79+
private void HeavyMethod()
80+
{
81+
for (int i = 0; i < 100000; i++)
82+
{
83+
float x = Mathf.Sqrt(i);
84+
}
85+
}
86+
87+
// Don't forget about disposing!
88+
private void OnDestroy() => _timer?.Dispose();
89+
}
90+
```
91+
92+
---
93+
94+
### 🎞️ Profile Sampling
95+
96+
```csharp
97+
using (_timer.Measure("Name of Sample"))
98+
{
99+
// Here you can call any methods you want to measure
100+
HeavyMethod();
101+
}
102+
```
103+
104+
And then after running with enabled Profile you'll see:
105+
106+
<img src="media/profilesampling.png" height="400">
107+
108+
---
109+
110+
### 🫡 Reset Timer
111+
112+
```csharp
113+
using (_timer.Measure("Name of Sample")) HeavyMethod();
114+
115+
if (_timer.State.countOfCalling == 1000) _timer.Reset();
116+
```
117+
118+
Result:
119+
120+
<img src="media/resettimer.png" height="400">
121+
122+
---
123+
124+
### That's it! Enjoy measuring your heavy stuff 😎
125+
126+
---
127+
128+
## 📄 License
129+
130+
This project is licensed under the **MIT License**.
131+
See the [LICENSE.md](LICENSE.md) file for full terms.

Unity/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
"displayName": "UltraTimerWindows",
55
"license": "MIT",
66
"licensesUrl": "https://github.com/HardCodeDev777/UltraTimerWindows/blob/main/LICENSE.md",
7-
"documentationUrl": "https://github.com/HardCodeDev777/UltraTimerWindows/blob/master/README.md",
8-
"description": "Ultra fast and high performance native timer for Unity using QueryPerformanceCounter from winapi",
7+
"documentationUrl": "https://github.com/HardCodeDev777/UltraTimerWindows/blob/main/README.md",
8+
"description": "Zero-allocation during measurement, native high-resolution timer for Unity, built on top of Windows QueryPerformanceCounter",
99
"unity": "2021.3",
10-
"type": "library",
1110
"keywords": [
1211
"performance",
1312
"native",
14-
"benchmarks",
1513
"windows",
1614
"ultratimerwindows"
1715
],

media/profilesampling.png

287 KB
Loading

media/resettimer.png

287 KB
Loading

0 commit comments

Comments
 (0)