From 174e1d7a1f84118ba7030d46ac371d331060b798 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Fri, 12 Jan 2024 09:35:40 -0800 Subject: [PATCH] Add MergePatch benchmark --- v5/bench_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 v5/bench_test.go diff --git a/v5/bench_test.go b/v5/bench_test.go new file mode 100644 index 0000000..d78a9f8 --- /dev/null +++ b/v5/bench_test.go @@ -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) + } +}