test(generatePrimes): Added benchmark functions
This commit is contained in:
parent
cca7fa0f95
commit
fe118fa685
21
main_test.go
Normal file
21
main_test.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func testGeneratePrimes(upperLimit int64, useTensors bool, b *testing.B) {
|
||||
var config Config
|
||||
config.DontLoad = true
|
||||
config.UseTensors = useTensors
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
generatePrimes(upperLimit, config)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkPrimes1000CPU(b *testing.B) {
|
||||
testGeneratePrimes(1000, false, b)
|
||||
}
|
||||
|
||||
func BenchmarkPrimes1000GPU(b *testing.B) {
|
||||
testGeneratePrimes(1000, true, b)
|
||||
}
|
Loading…
Reference in New Issue
Block a user