-
Notifications
You must be signed in to change notification settings - Fork 0
/
serial.go
120 lines (117 loc) · 2.29 KB
/
serial.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/pprof"
)
func J_expect_18_18(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func I_expect_16_36(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func H_expect_14_546(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func G_expect_12_73(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func F_expect_10_91(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func E_expect_9_09(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func D_expect_7_27(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func C_expect_5_46(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func B_expect_3_64(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func A_expect_1_82(v uint64, trip uint64) uint64 {
ret := v
for i := trip; i > 0; i-- {
ret += i
ret = ret ^ (i + 0xcafebabe)
}
return ret
}
func main() {
var q uint64
multiplier := flag.Uint64("m", 100000, "multiplier")
flag.Parse()
//fmt.Println("multiplier=", *multiplier)
file, err := os.Create("serial_prof")
if err != nil {
log.Fatal(err)
}
if err = pprof.StartCPUProfile(file); err != nil {
log.Fatal(err)
}
mult := *multiplier
for i := uint64(0); i < 100; i++ {
f := i + A_expect_1_82(0xebabefac23, 1*mult)
g := i + B_expect_3_64(f, 2*mult)
h := i + C_expect_5_46(g, 3*mult)
k := i + D_expect_7_27(h, 4*mult)
l := i + E_expect_9_09(k, 5*mult)
m := i + F_expect_10_91(l, 6*mult)
n := i + G_expect_12_73(m, 7*mult)
o := i + H_expect_14_546(n, 8*mult)
p := i + I_expect_16_36(o, 9*mult)
q = i + J_expect_18_18(p, 10*mult)
}
pprof.StopCPUProfile()
file.Close()
fmt.Println(q)
}