File: wrapper_benchmark_test.go

package info (click to toggle)
golang-github-huandu-go-clone 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: makefile: 2
file content (55 lines) | stat: -rw-r--r-- 852 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2019 Huan Du. All rights reserved.
// Licensed under the MIT license that can be found in the LICENSE file.

package clone

import "testing"

func BenchmarkUnwrap(b *testing.B) {
	orig := &testType{
		Foo: "abcd",
		Bar: map[string]interface{}{
			"def": 123,
			"ghi": 78.9,
		},
		Player: []float64{
			12.3, 45.6, -78.9,
		},
	}
	wrapped := Wrap(orig)
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		Unwrap(wrapped)
	}
}

func BenchmarkSimpleWrap(b *testing.B) {
	orig := &testSimple{
		Foo: 123,
		Bar: "abcd",
	}
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		Wrap(orig)
	}
}

func BenchmarkComplexWrap(b *testing.B) {
	orig := &testType{
		Foo: "abcd",
		Bar: map[string]interface{}{
			"def": 123,
			"ghi": 78.9,
		},
		Player: []float64{
			12.3, 45.6, -78.9,
		},
	}
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		Wrap(orig)
	}
}