Skip to content

Commit

Permalink
more benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed Dec 3, 2014
1 parent c73a234 commit 46a6243
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func packAnyMap(val map[interface{}]interface{}) ([]byte, error) {

func newPacker() *packer {
p := &packer{
buffer: bytes.NewBuffer(make([]byte, 0, 256)),
buffer: bytes.NewBuffer(make([]byte, 0, 64)),
}

return p
Expand Down
38 changes: 36 additions & 2 deletions performance/bench_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func doGet(set string, b *testing.B) {
}
}

func Benchmark_Get___________Int(b *testing.B) {
func Benchmark_Get_________Int64(b *testing.B) {
set := "get_bench_integer"
bins := []*Bin{NewBin("b", rand.Int63())}
makeDataForGetBench(set, bins)
Expand All @@ -55,6 +55,16 @@ func Benchmark_Get___________Int(b *testing.B) {
doGet(set, b)
}

func Benchmark_Get_________Int32(b *testing.B) {
set := "get_bench_integer"
bins := []*Bin{NewBin("b", rand.Int31())}
makeDataForGetBench(set, bins)
b.N = 1000
runtime.GC()
b.ResetTimer()
doGet(set, b)
}

func Benchmark_Get_String______1(b *testing.B) {
set := "get_bench_str_1"
bins := []*Bin{NewBin("b", strings.Repeat("s", 1))}
Expand Down Expand Up @@ -94,6 +104,7 @@ func Benchmark_Get_String___1000(b *testing.B) {
makeDataForGetBench(set, bins)
doGet(set, b)
}

func Benchmark_Get_String__10000(b *testing.B) {
set := "get_bench_str_10000"
bins := []*Bin{NewBin("b", strings.Repeat("s", 10000))}
Expand All @@ -103,13 +114,36 @@ func Benchmark_Get_String__10000(b *testing.B) {
makeDataForGetBench(set, bins)
doGet(set, b)
}

func Benchmark_Get_String_100000(b *testing.B) {
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()
set := "get_bench_str_10000"
bins := []*Bin{NewBin("b", strings.Repeat("s", 10000))}
b.N = 100000
b.N = 1000
runtime.GC()
b.ResetTimer()
makeDataForGetBench(set, bins)
doGet(set, b)
}

func Benchmark_Get_Complex_Array(b *testing.B) {
set := "get_bench_str_10000"
// bins := []*Bin{NewBin("b", []interface{}{"a simple string", nil, rand.Int63(), []byte{12, 198, 211}})}
bins := []*Bin{NewBin("b", []interface{}{rand.Int63()})}
b.N = 1000
runtime.GC()
b.ResetTimer()
makeDataForGetBench(set, bins)
doGet(set, b)
}

func Benchmark_Get_Complex_Map(b *testing.B) {
set := "get_bench_str_10000"
// bins := []*Bin{NewBin("b", []interface{}{"a simple string", nil, rand.Int63(), []byte{12, 198, 211}})}
bins := []*Bin{NewBin("b", map[interface{}]interface{}{rand.Int63(): rand.Int63()})}
b.N = 1000
runtime.GC()
b.ResetTimer()
makeDataForGetBench(set, bins)
Expand Down

0 comments on commit 46a6243

Please sign in to comment.