Skip to content

Commit

Permalink
tests: remove redundant Decimal_Sqr benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
db47h committed May 26, 2020
1 parent 1e9c133 commit 188baad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
9 changes: 4 additions & 5 deletions dec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,7 @@ func BenchmarkDecDigit(b *testing.B) {
}
}

// TODO(bd47h): move this to decimal_test
func benchmarkDecimalDiv(b *testing.B, aSize, bSize int) {
func benchmarkDecDiv(b *testing.B, aSize, bSize int) {
aa := rndDec1(aSize)
bb := rndDec1(bSize)
if aa.cmp(bb) < 0 {
Expand All @@ -771,12 +770,12 @@ func benchmarkDecimalDiv(b *testing.B, aSize, bSize int) {
}
}

func BenchmarkDecimalDiv(b *testing.B) {
sizes := []int{10, 20, 50, 100, 200, 500, 1000, 1e4}
func BenchmarkDecDiv(b *testing.B) {
sizes := []int{9, 19, 34, 75, 150, 300, 3000, 3e4}
for _, i := range sizes {
j := 2 * i
b.Run(fmt.Sprintf("%d/%d", j, i), func(b *testing.B) {
benchmarkDecimalDiv(b, j, i)
benchmarkDecDiv(b, j, i)
})
}
}
2 changes: 1 addition & 1 deletion decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"math/big"
)

const debugDecimal = true // enable for debugging
const debugDecimal = false // enable for debugging

// DefaultDecimalPrec is the default minimum precision used when creating a new
// Decimal from a *big.Int, *big.Rat, uint64, int64, or string. An uint64
Expand Down
8 changes: 0 additions & 8 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ func BenchmarkDecimal_dnorm(b *testing.B) {
_ = uint(dnorm(d))
}
}
func BenchmarkDecimal_Sqrt(b *testing.B) {
x := new(Decimal).SetUint64(2)
z := new(Decimal).SetPrec(34)
for i := 0; i < b.N; i++ {
z.Sqrt(x)
}
}

func BenchmarkDecimal_Float(b *testing.B) {
d := new(Decimal).SetPrec(100).SetUint64(2)
d.Sqrt(d)
Expand Down

0 comments on commit 188baad

Please sign in to comment.