(b *testing.B)
| 46 | } |
| 47 | |
| 48 | func 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 | |
| 72 | func TestNumDigits(t *testing.T) { |
| 73 | runTest := func(start string, c byte) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…