diff --git a/.gitignore b/.gitignore index becd7f9..c16e2e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ * !*/ !*.* +a.out diff --git a/examples/bench_perm.c b/examples/bench_perm.c new file mode 100644 index 0000000..b24b726 --- /dev/null +++ b/examples/bench_perm.c @@ -0,0 +1,74 @@ + +// $ gcc -O2 bench_perm.c ../cbits/goldilocks.c + +#include + +#include "../cbits/goldilocks.h" + +#include +#include +#include +#include +#include +#include + +//------------------------------------------------------------------------------ + +int64_t get_usec() { + int64_t start; + struct timeval timecheck; + gettimeofday(&timecheck, NULL); + start = (int64_t)timecheck.tv_sec * 1000000 + (int64_t)timecheck.tv_usec; + return start; +} + +void print_elapsed_time(const char *msg, int64_t start, int64_t stop) { + printf("%s took %lld usecs\n" ,msg, stop-start ); +} + +//------------------------------------------------------------------------------ + +void benchmark_poseidon2_perm(int N) { + printf("\nbenchmarking iterated Poseidon2 permutations with N = %d\n",N); + + uint64_t state[12]; + for(int i=0; i<12; i++) state[i] = i; + + int64_t start = get_usec(); + for(int i=0; i= 2) { + N = atoi(argv[1]); + } + + benchmark_poseidon2_perm(N); + benchmark_monolith_perm (N); + + return 0; +}