summaryrefslogtreecommitdiff
path: root/internal/statsengine/bench_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 12:14:44 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 12:14:44 +0200
commit7c5f331dd14e728979530abb589f5b3cbd6c971e (patch)
tree5acfa9db17452374a6b077177cd5ef7fd93c8141 /internal/statsengine/bench_test.go
parent610d91472b3b37010130f33bd835c23e859caf56 (diff)
statsengine: cache syscall percentiles between snapshots
Diffstat (limited to 'internal/statsengine/bench_test.go')
-rw-r--r--internal/statsengine/bench_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/statsengine/bench_test.go b/internal/statsengine/bench_test.go
new file mode 100644
index 0000000..27f17b1
--- /dev/null
+++ b/internal/statsengine/bench_test.go
@@ -0,0 +1,29 @@
+package statsengine
+
+import (
+ "ior/internal/types"
+ "math/rand"
+ "testing"
+ "time"
+)
+
+func BenchmarkSyscallAccumulatorSnapshot(b *testing.B) {
+ acc := newSyscallAccumulatorWithConfig(10_000, rand.New(rand.NewSource(123)))
+ traceIDs := []types.TraceId{
+ types.SYS_ENTER_READ,
+ types.SYS_ENTER_WRITE,
+ types.SYS_ENTER_OPENAT,
+ types.SYS_ENTER_CLOSE,
+ types.SYS_ENTER_COPY_FILE_RANGE,
+ }
+ for i := 0; i < 100_000; i++ {
+ id := traceIDs[i%len(traceIDs)]
+ acc.Add(newPair(id, uint64((i%2000)+1), uint64(i%65536), 0))
+ }
+
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ _ = acc.Snapshot(5 * time.Second)
+ }
+}