Skip to content

Commit edbd247

Browse files
committed
Use time.Stopwatch in core:bytes benchmark
This should result in a clearer idea of how fast the procedures are running, as the loop can run without going back and forth to the system for the time.
1 parent 4e49fb4 commit edbd247

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/benchmark/bytes/benchmark_bytes.odin

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ run_trial_size :: proc(p: proc "contextless" ([]u8, byte) -> int, size: int, idx
5454

5555
accumulator: int
5656

57+
watch: time.Stopwatch
58+
59+
time.stopwatch_start(&watch)
5760
for _ in 0..<runs {
58-
start := time.now()
5961
accumulator += p(data, 'z')
60-
done := time.since(start)
61-
timing += done
6262
}
63+
time.stopwatch_stop(&watch)
6364

64-
timing /= time.Duration(runs)
65+
timing = time.stopwatch_duration(watch)
6566

6667
log.debug(accumulator)
6768
return

0 commit comments

Comments
 (0)