-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbignum_test.go
55 lines (46 loc) · 1010 Bytes
/
bignum_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
package gson
import "strconv"
import "testing"
import "math/big"
func BenchmarkAtoi(b *testing.B) {
for i := 0; i < b.N; i++ {
strconv.Atoi("6744073709551615")
}
}
func BenchmarkBigParseFloat(b *testing.B) {
bf := big.NewFloat(0)
bf.SetPrec(64)
for i := 0; i < b.N; i++ {
bf.Parse("18446744073709551615", 0)
}
}
func BenchmarkBigUint64Fmt(b *testing.B) {
bf := big.NewFloat(0)
out := make([]byte, 0, 1024)
num := uint64(18446744073709551615)
bf.SetPrec(64)
bf.SetUint64(num)
for i := 0; i < b.N; i++ {
bf.Append(out, 'e', -1)
}
}
func BenchmarkBigInt64Fmt(b *testing.B) {
bf := big.NewFloat(0)
out := make([]byte, 0, 128)
num := int64(446744073709551615)
bf.SetPrec(64)
bf.SetInt64(num)
for i := 0; i < b.N; i++ {
bf.Append(out, 'e', -1)
}
}
func BenchmarkBigFloatFmt(b *testing.B) {
bf := big.NewFloat(0)
out := make([]byte, 0, 128)
num := float64(18446744073709551615.123)
bf.SetPrec(64)
bf.SetFloat64(num)
for i := 0; i < b.N; i++ {
bf.Append(out, 'e', -1)
}
}