Skip to content

Commit

Permalink
Add MergePatch benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Jan 12, 2024
1 parent 7b8895c commit 174e1d7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions v5/bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jsonpatch

import "testing"

func BenchmarkMergePatch(b *testing.B) {
original := []byte(`{"name": "John", "age": 24, "height": 3.21}`)
target := []byte(`{"name": "Jane", "age": 24}`)
alternative := []byte(`{"name": "Tina", "age": 28, "height": 3.75}`)

patch, err := CreateMergePatch(original, target)
if err != nil {
panic(err)
}

for n := 0; n < b.N; n++ {
MergePatch(alternative, patch)
}
}

0 comments on commit 174e1d7

Please sign in to comment.