initial commit

This commit is contained in:
2025-04-29 18:15:33 +02:00
commit f5fbad64d3
14 changed files with 931 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package traceIdTtlMap
import (
"strconv"
"testing"
)
func BenchmarkTTLMap_AddExists(b *testing.B) {
m := New(1000, 10)
defer m.Stop()
b.Run("Add", func(b *testing.B) {
for i := 0; b.Loop(); i++ {
m.Add(strconv.Itoa(i))
}
})
for i := range 1000 {
m.Add(strconv.Itoa(i))
}
b.Run("Exists", func(b *testing.B) {
for i := 0; i < b.N; i++ {
key := strconv.Itoa(i % 1000)
m.Exists(key)
}
})
}
func BenchmarkTTLMap_Concurrent(b *testing.B) {
m := New(1000, 10)
defer m.Stop()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
key := strconv.Itoa(i % 1000)
m.Add(key)
m.Exists(key)
i++
}
})
}