From 002ceae70e3116b22a63e1c603bbbc43b961f419 Mon Sep 17 00:00:00 2001 From: Balazs Komuves Date: Sat, 14 Oct 2023 20:11:28 +0200 Subject: [PATCH] initial Blake3 benchmark --- hash/cpu/bench/Blake3/Unix/.gitignore | 2 ++ hash/cpu/bench/Blake3/Unix/build.sh | 17 ++++++++++++ hash/cpu/bench/Blake3/Unix/fakedata.c | 38 +++++++++++++++++++++++++++ hash/cpu/bench/Blake3/Unix/run.sh | 2 ++ hash/cpu/bench/SHA256/Unix/.gitignore | 1 + hash/cpu/bench/SHA256/Unix/build.sh | 2 +- hash/cpu/bench/SHA256/Unix/run.sh | 2 +- 7 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 hash/cpu/bench/Blake3/Unix/.gitignore create mode 100755 hash/cpu/bench/Blake3/Unix/build.sh create mode 100644 hash/cpu/bench/Blake3/Unix/fakedata.c create mode 100644 hash/cpu/bench/Blake3/Unix/run.sh create mode 100644 hash/cpu/bench/SHA256/Unix/.gitignore diff --git a/hash/cpu/bench/Blake3/Unix/.gitignore b/hash/cpu/bench/Blake3/Unix/.gitignore new file mode 100644 index 0000000..336309a --- /dev/null +++ b/hash/cpu/bench/Blake3/Unix/.gitignore @@ -0,0 +1,2 @@ +fakedata +b3sum diff --git a/hash/cpu/bench/Blake3/Unix/build.sh b/hash/cpu/bench/Blake3/Unix/build.sh new file mode 100755 index 0000000..98984ae --- /dev/null +++ b/hash/cpu/bench/Blake3/Unix/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +ORIG=`pwd` +cd ../../src/Blake3/ +IMPL=`pwd` + +cd $IMPL +cargo build --release + +cd $IMPL/b3sum +cargo build --release + +cd $ORIG +cp $IMPL/b3sum/target/release/b3sum . + +gcc -O3 fakedata.c -o fakedata + diff --git a/hash/cpu/bench/Blake3/Unix/fakedata.c b/hash/cpu/bench/Blake3/Unix/fakedata.c new file mode 100644 index 0000000..0cfd5fe --- /dev/null +++ b/hash/cpu/bench/Blake3/Unix/fakedata.c @@ -0,0 +1,38 @@ + +// generate given amount of fake data to be hashed, and push it to standard output + +#include +#include + +void generate(megabytes) { + + unsigned char buffer[257]; + for(int i=0;i<256;i++) { buffer[i] = 1+(i%255); } + buffer[256] = 0; + + for(int i=0;i:\n"); + exit(-1); + break; + + } +} \ No newline at end of file diff --git a/hash/cpu/bench/Blake3/Unix/run.sh b/hash/cpu/bench/Blake3/Unix/run.sh new file mode 100644 index 0000000..eec4f89 --- /dev/null +++ b/hash/cpu/bench/Blake3/Unix/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./fakedata $ZKBENCH_MEGABYTES | ./b3sum --num-threads $ZKBENCH_NTHREADS - \ No newline at end of file diff --git a/hash/cpu/bench/SHA256/Unix/.gitignore b/hash/cpu/bench/SHA256/Unix/.gitignore new file mode 100644 index 0000000..e7f4e5c --- /dev/null +++ b/hash/cpu/bench/SHA256/Unix/.gitignore @@ -0,0 +1 @@ +fakedata diff --git a/hash/cpu/bench/SHA256/Unix/build.sh b/hash/cpu/bench/SHA256/Unix/build.sh index 8c74da7..e28c492 100755 --- a/hash/cpu/bench/SHA256/Unix/build.sh +++ b/hash/cpu/bench/SHA256/Unix/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -gcc -O3 fakedata.c +gcc -O3 fakedata.c -o fakedata diff --git a/hash/cpu/bench/SHA256/Unix/run.sh b/hash/cpu/bench/SHA256/Unix/run.sh index 43d81b7..6187869 100755 --- a/hash/cpu/bench/SHA256/Unix/run.sh +++ b/hash/cpu/bench/SHA256/Unix/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -./a.out $ZKBENCH_MEGABYTES | shasum -a256 -b - \ No newline at end of file +./fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b - \ No newline at end of file