File tree Expand file tree Collapse file tree 3 files changed +28
-12
lines changed
Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change 66 "sync"
77 "testing"
88
9+ "github.com/simar7/gokv/encoding"
10+
911 "github.com/simar7/gokv/types"
1012
1113 "github.com/stretchr/testify/assert"
@@ -14,7 +16,7 @@ import (
1416func benchmarkSet (j int , b * testing.B ) {
1517 b .ReportAllocs ()
1618
17- s , f , err := setupStore ( )
19+ s , f , err := setupStoreWithCodec ( encoding . JSON )
1820 defer func () {
1921 _ = f .Close ()
2022 _ = os .RemoveAll (f .Name ())
@@ -46,7 +48,7 @@ func benchmarkSet(j int, b *testing.B) {
4648func benchmarkBatchSet (j int , b * testing.B ) {
4749 b .ReportAllocs ()
4850
49- s , f , err := setupStore ( )
51+ s , f , err := setupStoreWithCodec ( encoding . JSON )
5052 defer func () {
5153 _ = f .Close ()
5254 _ = os .RemoveAll (f .Name ())
Original file line number Diff line number Diff line change @@ -17,16 +17,20 @@ import (
1717 "github.com/stretchr/testify/assert"
1818)
1919
20- func setupStore ( ) (* Store , * os.File , error ) {
20+ func setupStoreWithCodec ( codec encoding. Codec ) (* Store , * os.File , error ) {
2121 f , err := ioutil .TempFile ("." , "Bolt_TestStore_Get-*" )
2222 if err != nil {
2323 return nil , nil , err
2424 }
2525
26- s , err := NewStore (Options {Path : f .Name ()})
26+ s , err := NewStore (Options {Path : f .Name (), Codec : codec })
2727 return s , f , err
2828}
2929
30+ func setupStore () (* Store , * os.File , error ) {
31+ return setupStoreWithCodec (encoding .JSON )
32+ }
33+
3034func TestNewStore (t * testing.T ) {
3135 testCases := []struct {
3236 name string
Original file line number Diff line number Diff line change 11Format: Benchmark{Function_Name}_{Goroutine_Count}
22
3- BenchmarkStore_Set_10-8 7 148262680 ns/op 90536 B/op 561 allocs/op
4- BenchmarkStore_BatchSet_10-8 43 25739238 ns/op 14903 B/op 174 allocs/op
3+ Codec: JSON
4+ -----------
5+ BenchmarkStore_Set_10-8 4 287203197 ns/op 166494 B/op 1218 allocs/op
6+ BenchmarkStore_BatchSet_10-8 48 24649885 ns/op 17382 B/op 236 allocs/op
57
6- BenchmarkStore_Set_100-8 1 1389692456 ns/op 1800696 B/op 5729 allocs/op
7- BenchmarkStore_BatchSet_100-8 43 26573247 ns/op 69442 B/op 1182 allocs/op
8+ BenchmarkStore_Set_100-8 1 2686920561 ns/op 2456736 B/op 11318 allocs/op
9+ BenchmarkStore_BatchSet_100-8 48 24819310 ns/op 84989 B/op 1597 allocs/op
810
9- BenchmarkStore_Set_1000-8 1 14204090885 ns/op 29077600 B/op 61877 allocs/op
10- BenchmarkStore_BatchSet_1000-8 39 27656939 ns/op 685556 B/op 12515 allocs/op
11+ BenchmarkStore_Set_1000-8 1 26768086250 ns/op 36138808 B/op 120545 allocs/op
12+ BenchmarkStore_BatchSet_1000-8 42 28252055 ns/op 841488 B/op 16593 allocs/op
1113
12- BenchmarkStore_Set_10000-8 1 135506772987 ns/op 336269280 B/op 629670 allocs/op
13- BenchmarkStore_BatchSet_10000-8 6 168122801 ns/op 8537401 B/op 136949 allocs/op
14+ Codec: Gob
15+ ----------
16+ BenchmarkStore_Set_10-8 4 285566068 ns/op 173706 B/op 1323 allocs/op
17+ BenchmarkStore_BatchSet_10-8 46 24549045 ns/op 26445 B/op 345 allocs/op
18+
19+ BenchmarkStore_Set_100-8 1 2639456621 ns/op 2545608 B/op 12341 allocs/op
20+ BenchmarkStore_BatchSet_100-8 46 25044494 ns/op 166920 B/op 2609 allocs/op
21+
22+ BenchmarkStore_Set_1000-8 1 26472035638 ns/op 35322664 B/op 130541 allocs/op
23+ BenchmarkStore_BatchSet_1000-8 39 28649827 ns/op 1664744 B/op 26710 allocs/op
You can’t perform that action at this time.
0 commit comments