storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/metacache-bucket_test.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func Benchmark_bucketMetacache_findCache(b *testing.B) { 9 bm := newBucketMetacache("", false) 10 const elements = 50000 11 const paths = 100 12 if elements%paths != 0 { 13 b.Fatal("elements must be divisible by the number of paths") 14 } 15 var pathNames [paths]string 16 for i := range pathNames[:] { 17 pathNames[i] = fmt.Sprintf("prefix/%d", i) 18 } 19 for i := 0; i < elements; i++ { 20 bm.findCache(listPathOptions{ 21 ID: mustGetUUID(), 22 Bucket: "", 23 BaseDir: pathNames[i%paths], 24 Prefix: "", 25 FilterPrefix: "", 26 Marker: "", 27 Limit: 0, 28 AskDisks: 0, 29 Recursive: false, 30 Separator: slashSeparator, 31 Create: true, 32 CurrentCycle: uint64(i), 33 OldestCycle: uint64(i - 1), 34 }) 35 } 36 b.ReportAllocs() 37 b.ResetTimer() 38 for i := 0; i < b.N; i++ { 39 bm.findCache(listPathOptions{ 40 ID: mustGetUUID(), 41 Bucket: "", 42 BaseDir: pathNames[i%paths], 43 Prefix: "", 44 FilterPrefix: "", 45 Marker: "", 46 Limit: 0, 47 AskDisks: 0, 48 Recursive: false, 49 Separator: slashSeparator, 50 Create: true, 51 CurrentCycle: uint64(i % elements), 52 OldestCycle: uint64(0), 53 }) 54 } 55 }