package ocean_test import ( "testing" "git.akyoto.dev/go/assert" "git.akyoto.dev/go/ocean" ) func BenchmarkGet(b *testing.B) { users, err := ocean.New[User]("test", nil) assert.Nil(b, err) defer users.Sync() defer users.Clear() users.Set("1", &User{Name: "User 1"}) b.ReportAllocs() b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { _, _ = users.Get("1") } }) b.StopTimer() } func BenchmarkSet(b *testing.B) { users, err := ocean.New[User]("test", nil) assert.Nil(b, err) defer users.Sync() defer users.Clear() user := &User{Name: "User 1"} b.ReportAllocs() b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { users.Set("1", user) } }) b.StopTimer() } func BenchmarkDelete(b *testing.B) { users, err := ocean.New[User]("test", nil) assert.Nil(b, err) defer users.Sync() defer users.Clear() b.ReportAllocs() b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { users.Delete("1") } }) b.StopTimer() } func BenchmarkNew(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { _, _ = ocean.New[User]("test", nil) } }) }