initial Blake3 benchmark

This commit is contained in:
Balazs Komuves 2023-10-14 20:11:28 +02:00
parent f94131a109
commit 002ceae70e
7 changed files with 62 additions and 2 deletions

2
hash/cpu/bench/Blake3/Unix/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
fakedata
b3sum

View File

@ -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

View File

@ -0,0 +1,38 @@
// generate given amount of fake data to be hashed, and push it to standard output
#include <stdio.h>
#include <stdlib.h>
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<megabytes;i++) {
for(int j=0;j<4096;j++) {
fputs( (char*)buffer, stdout);
}
}
}
int main( int argc, char *argv[] ) {
int megabytes = 1;
switch(argc) {
case 2:
megabytes = atoi(argv[1]);
generate(megabytes);
break;
default:
printf("usage:\n");
printf("$ fakedata <amount_in_megabytes>:\n");
exit(-1);
break;
}
}

View File

@ -0,0 +1,2 @@
#!/bin/bash
./fakedata $ZKBENCH_MEGABYTES | ./b3sum --num-threads $ZKBENCH_NTHREADS -

1
hash/cpu/bench/SHA256/Unix/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
fakedata

View File

@ -1,3 +1,3 @@
#!/bin/bash
gcc -O3 fakedata.c
gcc -O3 fakedata.c -o fakedata

View File

@ -1,3 +1,3 @@
#!/bin/bash
./a.out $ZKBENCH_MEGABYTES | shasum -a256 -b -
./fakedata $ZKBENCH_MEGABYTES | shasum -a256 -b -