Commit aa885cd
fix(benchmarks): use clock_gettime(CLOCK_MONOTONIC) on native_sim for real timing
native_sim compiles to a native Linux binary, so the host POSIX clock is
directly available. Both Zephyr's timing_counter_get() and k_uptime_get_32()
measure the simulated Zephyr kernel clock which does NOT advance during
CPU-bound loops (it only advances on timer interrupts). Result: always 0.
clock_gettime(CLOCK_MONOTONIC) reads the host kernel's real monotonic clock,
giving true nanosecond-resolution wall-clock timing for the benchmark loops.
Guarded by CONFIG_NATIVE_SIMULATOR so real hardware targets fall back to
the Zephyr timing API (k_cycle_get_64 / sys_clock_hw_cycles_per_sec).
Co-Authored-By: Oz <oz-agent@warp.dev>1 parent 9aa63c3 commit aa885cd
2 files changed
Lines changed: 52 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
17 | 39 | | |
18 | 40 | | |
19 | 41 | | |
| |||
117 | 139 | | |
118 | 140 | | |
119 | 141 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 142 | | |
126 | 143 | | |
127 | 144 | | |
| |||
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
145 | | - | |
| 162 | + | |
146 | 163 | | |
147 | 164 | | |
148 | 165 | | |
| |||
151 | 168 | | |
152 | 169 | | |
153 | 170 | | |
154 | | - | |
155 | | - | |
| 171 | + | |
| 172 | + | |
156 | 173 | | |
157 | 174 | | |
158 | 175 | | |
| |||
199 | 216 | | |
200 | 217 | | |
201 | 218 | | |
202 | | - | |
| 219 | + | |
203 | 220 | | |
204 | 221 | | |
205 | 222 | | |
| |||
219 | 236 | | |
220 | 237 | | |
221 | 238 | | |
222 | | - | |
223 | | - | |
| 239 | + | |
| 240 | + | |
224 | 241 | | |
225 | 242 | | |
226 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
25 | 41 | | |
26 | 42 | | |
27 | 43 | | |
| |||
141 | 157 | | |
142 | 158 | | |
143 | 159 | | |
144 | | - | |
| 160 | + | |
145 | 161 | | |
146 | 162 | | |
147 | 163 | | |
148 | 164 | | |
149 | 165 | | |
150 | 166 | | |
151 | | - | |
152 | | - | |
| 167 | + | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
| |||
198 | 214 | | |
199 | 215 | | |
200 | 216 | | |
201 | | - | |
| 217 | + | |
202 | 218 | | |
203 | 219 | | |
204 | 220 | | |
| |||
214 | 230 | | |
215 | 231 | | |
216 | 232 | | |
217 | | - | |
218 | | - | |
| 233 | + | |
| 234 | + | |
219 | 235 | | |
220 | 236 | | |
221 | 237 | | |
| |||
0 commit comments