MCPcopy Create free account
hub / github.com/cockroachdb/apd / BenchmarkDecimalString

Function BenchmarkDecimalString

bench_test.go:107–124  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

105}
106
107func BenchmarkDecimalString(b *testing.B) {
108 rng := rand.New(rand.NewSource(461210934723948))
109 corpus := func() []Decimal {
110 res := make([]Decimal, 8192)
111 for i := range res {
112 _, err := res[i].SetFloat64(rng.Float64())
113 if err != nil {
114 b.Fatal(err)
115 }
116 }
117 return res
118 }()
119 b.ResetTimer()
120 b.ReportAllocs()
121 for i := 0; i < b.N; i++ {
122 _ = corpus[rng.Intn(len(corpus))].String()
123 }
124}
125
126func BenchmarkDecimalSetFloat(b *testing.B) {
127 rng := rand.New(rand.NewSource(461210934723948))

Callers

nothing calls this directly

Calls 3

SetFloat64Method · 0.80
Float64Method · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…