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

Function BenchmarkNumDigitsFull

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

Source from the content-addressed store, hash-verified

46}
47
48func BenchmarkNumDigitsFull(b *testing.B) {
49 prep := func(start string, c byte) []*Decimal {
50 var ds []*Decimal
51 buf := bytes.NewBufferString(start)
52 for i := 1; i < 1000; i++ {
53 buf.WriteByte(c)
54 d, _, _ := NewFromString(buf.String())
55 ds = append(ds, d)
56 }
57 return ds
58 }
59 var ds []*Decimal
60 ds = append(ds, prep("", '9')...)
61 ds = append(ds, prep("1", '0')...)
62 ds = append(ds, prep("-", '9')...)
63 ds = append(ds, prep("-1", '0')...)
64 b.ResetTimer()
65 for i := 0; i < b.N; i++ {
66 for _, d := range ds {
67 d.NumDigits()
68 }
69 }
70}
71
72func TestNumDigits(t *testing.T) {
73 runTest := func(start string, c byte) {

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…