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

Function BenchmarkNumDigitsLookup

table_test.go:24–46  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

22)
23
24func BenchmarkNumDigitsLookup(b *testing.B) {
25 prep := func(start string, c byte) []*Decimal {
26 var ds []*Decimal
27 buf := bytes.NewBufferString(start)
28 for i := 1; i < digitsTableSize; i++ {
29 buf.WriteByte(c)
30 d, _, _ := NewFromString(buf.String())
31 ds = append(ds, d)
32 }
33 return ds
34 }
35 var ds []*Decimal
36 ds = append(ds, prep("", '9')...)
37 ds = append(ds, prep("1", '0')...)
38 ds = append(ds, prep("-", '9')...)
39 ds = append(ds, prep("-1", '0')...)
40 b.ResetTimer()
41 for i := 0; i < b.N; i++ {
42 for _, d := range ds {
43 d.NumDigits()
44 }
45 }
46}
47
48func BenchmarkNumDigitsFull(b *testing.B) {
49 prep := func(start string, c byte) []*Decimal {

Callers

nothing calls this directly

Calls 3

NewFromStringFunction · 0.85
NumDigitsMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…