Debian Codegraph @

wrapper_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 BenchmarkUnwrap(b *testing.B) {
9 orig := &testType{
10 Foo: "abcd",
11 Bar: map[string]interface{}{
12 "def": 123,
13 "ghi": 78.9,
14 },
15 Player: []float64{
16 12.3, 45.6, -78.9,
17 },
18 }
19 wrapped := Wrap(orig)
20 b.ResetTimer()
21
22 for i := 0; i < b.N; i++ {
23 Unwrap(wrapped)
24 }
25 }
26
27 func BenchmarkSimpleWrap(b *testing.B) {
28 orig := &testSimple{
29 Foo: 123,
30 Bar: "abcd",
31 }
32 b.ResetTimer()
33
34 for i := 0; i < b.N; i++ {
35 Wrap(orig)
36 }
37 }
38
39 func BenchmarkComplexWrap(b *testing.B) {
40 orig := &testType{
41 Foo: "abcd",
42 Bar: map[string]interface{}{
43 "def": 123,
44 "ghi": 78.9,
45 },
46 Player: []float64{
47 12.3, 45.6, -78.9,
48 },
49 }
50 b.ResetTimer()
51
52 for i := 0; i < b.N; i++ {
53 Wrap(orig)
54 }
55 }