Add benches to the test suite to prevent forgetting about updating them

This commit is contained in:
Mamy André-Ratsimbazafy 2020-04-15 19:46:25 +02:00
parent ce350d1dac
commit d7e170288f
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
1 changed files with 24 additions and 10 deletions

View File

@ -26,6 +26,17 @@ proc test(flags, path: string) =
echo "========================================================================================"
exec "nim " & lang & cc & " " & flags & " --verbosity:0 --outdir:build -r --hints:off --warnings:off " & path
proc runBench(benchName: string, compiler = "") =
if not dirExists "build":
mkDir "build"
var cc = ""
if compiler != "":
cc = "--cc:" & compiler
exec "nim c " & cc &
" -d:danger --verbosity:0 -o:build/" & benchName & "_" & compiler &
" -r --hints:off --warnings:off benchmarks/" & benchName & ".nim"
### tasks
task test, "Run all tests":
# -d:testingCurves is configured in a *.nim.cfg for convenience
@ -85,6 +96,13 @@ task test, "Run all tests":
# Elliptic curve arithmetic
test "-d:Constantine32", "tests/test_ec_weierstrass_projective_g1.nim"
# Benchmarks compile and run
runBench("bench_fp")
runBench("bench_fp2")
runBench("bench_fp6")
runBench("bench_fp12")
runBench("bench_ec_swei_proj_g1")
task test_no_gmp, "Run tests that don't require GMP":
# -d:testingCurves is configured in a *.nim.cfg for convenience
@ -135,16 +153,12 @@ task test_no_gmp, "Run tests that don't require GMP":
# Elliptic curve arithmetic
test "-d:Constantine32", "tests/test_ec_weierstrass_projective_g1.nim"
proc runBench(benchName: string, compiler = "") =
if not dirExists "build":
mkDir "build"
var cc = ""
if compiler != "":
cc = "--cc:" & compiler
exec "nim c " & cc &
" -d:danger --verbosity:0 -o:build/" & benchName & "_" & compiler &
" -r --hints:off --warnings:off benchmarks/" & benchName & ".nim"
# Benchmarks compile and run
runBench("bench_fp")
runBench("bench_fp2")
runBench("bench_fp6")
runBench("bench_fp12")
runBench("bench_ec_swei_proj_g1")
task bench_fp, "Run benchmark 𝔽p with your default compiler":
runBench("bench_fp")