(b *testing.B)
| 2075 | } |
| 2076 | |
| 2077 | func BenchmarkDBBatchSingle(b *testing.B) { |
| 2078 | db := btesting.MustCreateDB(b) |
| 2079 | if err := db.Update(func(tx *bolt.Tx) error { |
| 2080 | _, err := tx.CreateBucket([]byte("bench")) |
| 2081 | return err |
| 2082 | }); err != nil { |
| 2083 | b.Fatal(err) |
| 2084 | } |
| 2085 | |
| 2086 | b.ResetTimer() |
| 2087 | for i := 0; i < b.N; i++ { |
| 2088 | start := make(chan struct{}) |
| 2089 | var wg sync.WaitGroup |
| 2090 | |
| 2091 | for round := 0; round < 1000; round++ { |
| 2092 | wg.Add(1) |
| 2093 | go func(id uint32) { |
| 2094 | defer wg.Done() |
| 2095 | <-start |
| 2096 | |
| 2097 | h := fnv.New32a() |
| 2098 | buf := make([]byte, 4) |
| 2099 | binary.LittleEndian.PutUint32(buf, id) |
| 2100 | _, _ = h.Write(buf[:]) |
| 2101 | k := h.Sum(nil) |
| 2102 | insert := func(tx *bolt.Tx) error { |
| 2103 | b := tx.Bucket([]byte("bench")) |
| 2104 | return b.Put(k, []byte("filler")) |
| 2105 | } |
| 2106 | if err := db.Update(insert); err != nil { |
| 2107 | b.Error(err) |
| 2108 | return |
| 2109 | } |
| 2110 | }(uint32(round)) |
| 2111 | } |
| 2112 | close(start) |
| 2113 | wg.Wait() |
| 2114 | } |
| 2115 | |
| 2116 | b.StopTimer() |
| 2117 | validateBatchBench(b, db) |
| 2118 | } |
| 2119 | |
| 2120 | func BenchmarkDBBatchManual10x100(b *testing.B) { |
| 2121 | db := btesting.MustCreateDB(b) |
nothing calls this directly
no test coverage detected