MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / BenchmarkTx_LargeValues

Function BenchmarkTx_LargeValues

tx_btree_bench_test.go:384–416  ·  view source on GitHub ↗

Benchmark large value operations

(b *testing.B)

Source from the content-addressed store, hash-verified

382
383// Benchmark large value operations
384func BenchmarkTx_LargeValues(b *testing.B) {
385 dir := b.TempDir()
386 db := setupBenchmarkDB(b, dir)
387 defer cleanupBenchmarkDB(db, dir)
388
389 // Create a large value (64KB)
390 largeValue := make([]byte, 64*1024)
391 for i := range largeValue {
392 largeValue[i] = byte(i % 256)
393 }
394
395 b.ResetTimer()
396 b.ReportAllocs()
397
398 for i := 0; i < b.N; i++ {
399 key := []byte(fmt.Sprintf("large_key_%d", i))
400
401 err := db.Update(func(tx *Tx) error {
402 return tx.Put("test_bucket", key, largeValue, Persistent)
403 })
404 if err != nil {
405 b.Fatalf("Large value Put failed: %v", err)
406 }
407
408 err = db.View(func(tx *Tx) error {
409 _, err := tx.Get("test_bucket", key)
410 return err
411 })
412 if err != nil {
413 b.Fatalf("Large value Get failed: %v", err)
414 }
415 }
416}
417
418// Benchmark transaction commit performance
419func BenchmarkTx_TransactionCommit(b *testing.B) {

Callers

nothing calls this directly

Calls 6

setupBenchmarkDBFunction · 0.85
cleanupBenchmarkDBFunction · 0.85
UpdateMethod · 0.80
ViewMethod · 0.80
PutMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected