mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 15:16:59 +08:00
mat: add benchmarks for Sum with Dense, SymDense, TriDense and VecDense
This commit is contained in:

committed by
Dan Kortschak

parent
30fedc02ce
commit
48323a4c88
@@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user