Skip to content

Commit

Permalink
test: add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
5aaee9 committed Jun 7, 2023
1 parent 2701698 commit 71bb3c4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkgs/objects/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ func TestRemarshJSONReflect(t *testing.T) {
assert.Equal(t, out.Data, "data test #1")
assert.Equal(t, ptr.Data, "")
}

func BenchmarkRemarshJSON(b *testing.B) {
data := json.JSON{
"test": "data test #1",
}

for n := 0; n < b.N; n++ {
objects.RemarshJSON[TestStruct](data)
}
}

func BenchmarkRemarshJSONReflect(b *testing.B) {
data := json.JSON{
"test": "data test #1",
}
kind := reflect.TypeOf(TestStruct{})

for n := 0; n < b.N; n++ {
objects.RemarshJSONReflect[TestStruct](data, kind)
}
}

0 comments on commit 71bb3c4

Please sign in to comment.