-
Notifications
You must be signed in to change notification settings - Fork 12
/
pcopy_benchmark_getredpoint_test.go
58 lines (50 loc) · 1.16 KB
/
pcopy_benchmark_getredpoint_test.go
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
56
57
58
// Copyright [2020-2023] [guonaihong]
package pcopy
import (
"testing"
)
func Benchmark_GetRedPoint_Unsafe_Pcopy(b *testing.B) {
err := Preheat(&GetRedPointResp{}, &GetRedPointRespData{})
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
rv := GetRedPointResp{}
err := Copy(&rv.Data, &local_GetRedPointRespData, WithUsePreheat())
if err != nil {
b.Fatal(err)
}
}
}
func Benchmark_GetRedPoint_RawCopy(b *testing.B) {
for i := 0; i < b.N; i++ {
var dst GetRedPointResp
dst.Data = &GetRedPointResp_GetRedPointRespData{}
dst.Data.Point = make(map[uint32]uint32)
for k, v := range local_GetRedPointRespData.Point {
dst.Data.Point[k] = v
}
}
}
func Benchmark_GetRedPoint_MiniCopy(b *testing.B) {
for i := 0; i < b.N; i++ {
// var dst testData
rv := GetRedPointResp{}
err := miniCopy(&rv.Data, local_GetRedPointRespData)
if err != nil {
b.Fatal(err)
}
// miniCopy(&dst, &td)
}
}
func Benchmark_GetRedPoint_Reflect_Pcopy(b *testing.B) {
for i := 0; i < b.N; i++ {
// var dst testData
rv := GetRedPointResp{}
err := Copy(&rv.Data, &local_GetRedPointRespData)
if err != nil {
b.Fatal(err)
}
}
}