add SHA256 benchmark via the Unix tool and pipes

This commit is contained in:
Balazs Komuves 2023-10-14 18:23:51 +02:00
parent fadfcf6e5f
commit 4b8a5554b1
3 changed files with 44 additions and 0 deletions

View File

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

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,3 @@
#!/bin/bash
./a.out $ZKBENCH_MEGABYTES | shasum -a256 -b -