(b *testing.B)
| 22 | ) |
| 23 | |
| 24 | func 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 | |
| 48 | func BenchmarkNumDigitsFull(b *testing.B) { |
| 49 | prep := func(start string, c byte) []*Decimal { |
nothing calls this directly
no test coverage detected
searching dependent graphs…