MCPcopy Create free account
hub / github.com/dgraph-io/dgraph-benchmarks / BenchmarkCaches

Function BenchmarkCaches

cachebench/cache_bench_test.go:360–421  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

358}
359
360func BenchmarkCaches(b *testing.B) {
361 zipfList := zipfKeyList()
362 oneList := oneKeyList()
363
364 // two datasets (zipf, onekey)
365 // 3 caches (bigcache, freecache, sync.Map)
366 // 3 types of benchmark (read, write, mixed)
367 benchmarks := []struct {
368 name string
369 cache Cache
370 keys [][]byte
371 pctWrites uint64
372 }{
373 {"BigCacheZipfRead", newBigCache(b.N), zipfList, 0},
374 {"FastCacheZipfRead", newFastCache(b.N), zipfList, 0},
375 {"FreeCacheZipfRead", newFreeCache(b.N), zipfList, 0},
376 {"GroupCacheZipfRead", newGroupCache(b.N), zipfList, 0},
377 {"RistrettoZipfRead", newRistretto(b.N), zipfList, 0},
378 {"SyncMapZipfRead", newSyncMap(), zipfList, 0},
379
380 {"BigCacheOneKeyRead", newBigCache(b.N), oneList, 0},
381 {"FastCacheOneKeyRead", newFastCache(b.N), oneList, 0},
382 {"FreeCacheOneKeyRead", newFreeCache(b.N), oneList, 0},
383 {"GroupCacheOneKeyRead", newGroupCache(b.N), oneList, 0},
384 {"RistrettoOneKeyRead", newRistretto(b.N), oneList, 0},
385 {"SyncMapOneKeyRead", newSyncMap(), oneList, 0},
386
387 {"BigCacheZipfWrite", newBigCache(b.N), zipfList, 100},
388 {"FastCacheZipfWrite", newFastCache(b.N), zipfList, 100},
389 {"FreeCacheZipfWrite", newFreeCache(b.N), zipfList, 100},
390 {"GroupCacheZipfWrite", newGroupCache(b.N), zipfList, 100},
391 {"RistrettoZipfWrite", newRistretto(b.N), zipfList, 100},
392 {"SyncMapZipfWrite", newSyncMap(), zipfList, 100},
393
394 {"BigCacheOneKeyWrite", newBigCache(b.N), oneList, 100},
395 {"FastCacheOneKeyWrite", newFastCache(b.N), oneList, 100},
396 {"FreeCacheOneKeyWrite", newFreeCache(b.N), oneList, 100},
397 {"GroupCacheOneKeyWrite", newGroupCache(b.N), oneList, 100},
398 {"RistrettoOneKeyWrite", newRistretto(b.N), oneList, 100},
399 {"SyncMapOneKeyWrite", newSyncMap(), oneList, 100},
400
401 {"BigCacheZipfMixed", newBigCache(b.N), zipfList, 25},
402 {"FastCacheZipfMixed", newFastCache(b.N), zipfList, 25},
403 {"FreeCacheZipfMixed", newFreeCache(b.N), zipfList, 25},
404 {"GroupCacheZipfMixed", newGroupCache(b.N), zipfList, 25},
405 {"RistrettoZipfMixed", newRistretto(b.N), zipfList, 25},
406 {"SyncMapZipfMixed", newSyncMap(), zipfList, 25},
407
408 {"BigCacheOneKeyMixed", newBigCache(b.N), oneList, 25},
409 {"FastCacheOneKeyMixed", newFastCache(b.N), oneList, 25},
410 {"FreeCacheOneKeyMixed", newFreeCache(b.N), oneList, 25},
411 {"GroupCacheOneKeyMixed", newGroupCache(b.N), oneList, 25},
412 {"RistrettoOneKeyMixed", newRistretto(b.N), oneList, 25},
413 {"SyncMapOneKeyMixed", newSyncMap(), oneList, 25},
414 }
415
416 for _, bm := range benchmarks {
417 b.Run(bm.name, func(b *testing.B) {

Callers

nothing calls this directly

Calls 9

zipfKeyListFunction · 0.85
oneKeyListFunction · 0.85
newBigCacheFunction · 0.85
newFastCacheFunction · 0.85
newFreeCacheFunction · 0.85
newGroupCacheFunction · 0.85
newRistrettoFunction · 0.85
newSyncMapFunction · 0.85
runCacheBenchmarkFunction · 0.85

Tested by

no test coverage detected