Debian Codegraph @

clone_benchmark_test.go

raw
1 // Copyright 2019 Huan Du. All rights reserved.
2 // Licensed under the MIT license that can be found in the LICENSE file.
3
4 package clone
5
6 import "testing"
7
8 func BenchmarkSimpleClone(b *testing.B) {
9 orig := &testSimple{
10 Foo: 123,
11 Bar: "abcd",
12 }
13 b.ResetTimer()
14
15 for i := 0; i < b.N; i++ {
16 Clone(orig)
17 }
18 }
19
20 func BenchmarkComplexClone(b *testing.B) {
21 m := map[string]*T{
22 "abc": {
23 Foo: 123,
24 Bar: map[string]interface{}{
25 "abc": 321,
26 },
27 },
28 "def": {
29 Foo: 456,
30 Bar: map[string]interface{}{
31 "def": 789,
32 },
33 },
34 }
35 b.ResetTimer()
36
37 for i := 0; i < b.N; i++ {
38 Clone(m)
39 }
40 }