mat: add benchmarks for Sum with Dense, SymDense, TriDense and VecDense

This commit is contained in:
jonreiter@gmail.com
2019-04-03 15:47:20 +08:00
committed by Dan Kortschak
parent 30fedc02ce
commit 48323a4c88
4 changed files with 72 additions and 0 deletions

View File

@@ -561,3 +561,15 @@ func randVecDense(size, inc int, rho float64, rnd func() float64) *VecDense {
},
}
}
func BenchmarkVectorSum100000(b *testing.B) { vectorSumBench(b, 100000) }
var vectorSumForBench float64
func vectorSumBench(b *testing.B, size int) {
a := randVecDense(size, 1, 1.0, rand.NormFloat64)
b.ResetTimer()
for i := 0; i < b.N; i++ {
vectorSumForBench = Sum(a)
}
}