test(generatePrimes): Added benchmark functions

This commit is contained in:
datalore 2024-10-03 13:47:48 +02:00
parent cca7fa0f95
commit fe118fa685

21
main_test.go Normal file
View 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)
}