瀏覽代碼

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.
Feoramund 3 月之前
父節點
當前提交
edbd247972
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      tests/benchmark/bytes/benchmark_bytes.odin

+ 5 - 4
tests/benchmark/bytes/benchmark_bytes.odin

@@ -54,14 +54,15 @@ run_trial_size :: proc(p: proc "contextless" ([]u8, byte) -> int, size: int, idx
 
 	accumulator: int
 
+	watch: time.Stopwatch
+
+	time.stopwatch_start(&watch)
 	for _ in 0..<runs {
-		start := time.now()
 		accumulator += p(data, 'z')
-		done := time.since(start)
-		timing += done
 	}
+	time.stopwatch_stop(&watch)
 
-	timing /= time.Duration(runs)
+	timing = time.stopwatch_duration(watch)
 
 	log.debug(accumulator)
 	return