MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkTable_Get

Function BenchmarkTable_Get

internal/utils/kvstore/table_test.go:345–381  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

343}
344
345func BenchmarkTable_Get(b *testing.B) {
346 runtime.GOMAXPROCS(4)
347
348 store, err := kvstore.OpenStore("test")
349 if err != nil {
350 b.Fatal(err)
351 }
352 defer func() {
353 _ = store.Close()
354 }()
355
356 db, err := store.NewDB("TEST_DB")
357 if err != nil {
358 b.Fatal(err)
359 }
360
361 table, err := kvstore.NewTable[uint8]("users", kvstore.NewIntValueEncoder[uint8]())
362 if err != nil {
363 b.Fatal(err)
364 }
365
366 db.AddTable(table)
367
368 b.ResetTimer()
369
370 b.RunParallel(func(pb *testing.PB) {
371 for pb.Next() {
372 _, putErr := table.Get(types.String(rand.Int()))
373 if putErr != nil {
374 if kvstore.IsNotFound(putErr) {
375 continue
376 }
377 b.Fatal(putErr)
378 }
379 }
380 })
381}
382
383/**func BenchmarkTable_NextId(b *testing.B) {
384 runtime.GOMAXPROCS(4)

Callers

nothing calls this directly

Calls 8

AddTableMethod · 0.95
OpenStoreFunction · 0.92
IsNotFoundFunction · 0.92
NewDBMethod · 0.80
NextMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected