From c0fc8803ac7f73abb349170195e75b34f0ec072a Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Wed, 19 Jun 2024 14:52:25 +0800 Subject: [PATCH] add benchmarking script Signed-off-by: Matthias J. Kannwischer --- scripts/tests | 21 +++++++++++++++++++++ test/bench_kyber.c | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/tests b/scripts/tests index b3fb9220e..0e722b4ef 100755 --- a/scripts/tests +++ b/scripts/tests @@ -66,6 +66,8 @@ def base_run(bin, force_qemu, verbose): capture_output=True, universal_newlines=False, ) + if verbose: + print(result.stdout.decode()) return result.stdout @@ -254,6 +256,24 @@ def kat(force_qemu, verbose): ) +@click.command( + short_help="Run the benchmarks for all parameter sets", + context_settings={"show_default": True}, +) +@add_options(_shared_options) +def bench(force_qemu, verbose): + config_logger(verbose) + + test_schemes( + "benchmark", + lambda scheme: scheme.name.replace("MLKEM", "test/bin/bench_kyber"), + lambda _: True, + lambda _: True, + force_qemu, + verbose, + ) + + @click.group(invoke_without_command=True) def cli(): pass @@ -263,6 +283,7 @@ cli.add_command(run) cli.add_command(func) cli.add_command(nistkat) cli.add_command(kat) +cli.add_command(bench) if __name__ == "__main__": cli() diff --git a/test/bench_kyber.c b/test/bench_kyber.c index a96425a90..6025c74d0 100644 --- a/test/bench_kyber.c +++ b/test/bench_kyber.c @@ -7,9 +7,9 @@ #include "hal.h" #include "randombytes.h" -#define NWARMUP 10 -#define NITERERATIONS 100 -#define NTESTS 100 +#define NWARMUP 50 +#define NITERERATIONS 300 +#define NTESTS 200 static int cmp_uint64_t(const void *a, const void *b) {