Skip to content

Commit

Permalink
Add benchmark code.
Browse files Browse the repository at this point in the history
  • Loading branch information
harukasan committed Jul 19, 2017
1 parent be535bc commit 8e1a247
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,32 @@ func TestMarshal(t *testing.T) {
}
}
}

func BenchmarkMarshalStruct(b *testing.B) {
input := &ss{
User: "songmu",
Age: 36,
Height: pfloat64(169.1),
Weight: 66.6,
Memo: "songmu.jp",
}
for i := 0; i < b.N; i++ {
_, err := Marshal(input)
if err != nil {
b.Error(err)
}
}
}

func BenchmarkMarshalMap(b *testing.B) {
input := map[string]string{
"hoge": "fuga",
"piyo": "piyo",
}
for i := 0; i < b.N; i++ {
_, err := Marshal(input)
if err != nil {
b.Error(err)
}
}
}

0 comments on commit 8e1a247

Please sign in to comment.