summaryrefslogtreecommitdiff
path: root/internal/streamrow/bench_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/streamrow/bench_test.go')
-rw-r--r--internal/streamrow/bench_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/streamrow/bench_test.go b/internal/streamrow/bench_test.go
new file mode 100644
index 0000000..ea75dd9
--- /dev/null
+++ b/internal/streamrow/bench_test.go
@@ -0,0 +1,34 @@
+package streamrow
+
+import (
+ "testing"
+
+ "ior/internal/event"
+ "ior/internal/file"
+ "ior/internal/types"
+)
+
+var benchmarkRowSink Row
+
+func BenchmarkNew(b *testing.B) {
+ pair := benchmarkPair()
+
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ benchmarkRowSink = New(uint64(i+1), pair)
+ }
+}
+
+func benchmarkPair() *event.Pair {
+ enter := &types.OpenEvent{TraceId: types.SYS_ENTER_OPENAT, Time: 1234, Pid: 42, Tid: 84}
+ exit := &types.RetEvent{TraceId: types.SYS_EXIT_OPENAT, Time: 1300, Ret: 64, Pid: 42, Tid: 84}
+ pair := event.NewPair(enter)
+ pair.ExitEv = exit
+ pair.File = file.NewFd(7, "/tmp/bench.txt", 0)
+ pair.Comm = "bench"
+ pair.Duration = 66
+ pair.DurationToPrev = 19
+ pair.Bytes = 512
+ return pair
+}