MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / generateTestData

Function generateTestData

auth/password_hash_test.go:386–401  ·  view source on GitHub ↗

generateTestData generates the test data and warm up the cache if required.

(b *testing.B, cache Cache, warmCache bool, key string, numPasswords int)

Source from the content-addressed store, hash-verified

384
385// generateTestData generates the test data and warm up the cache if required.
386func generateTestData(b *testing.B, cache Cache, warmCache bool, key string, numPasswords int) []hashAndPassword {
387 hashAndPasswords := make([]hashAndPassword, numPasswords)
388 for i := 0; i < numPasswords; i++ {
389 password := []byte(fmt.Sprintf("%s%d", key, i))
390 hashAndPassword := hashAndPassword{
391 hash: bcryptHash(b, password),
392 password: password,
393 }
394 hashAndPasswords[i] = hashAndPassword
395 if warmCache {
396 key := authKey(hashAndPassword.hash, hashAndPassword.password)
397 cache.Put(key)
398 }
399 }
400 return hashAndPasswords
401}
402
403func BenchmarkCompareHashAndPassword100PercentCacheHit(b *testing.B) {
404 const maxCacheSize = 100

Calls 3

bcryptHashFunction · 0.85
authKeyFunction · 0.85
PutMethod · 0.65

Tested by

no test coverage detected