stasis-aries-wal/benchmarks/hashPerformance.c

35 lines
976 B
C
Raw Normal View History

/*
* hashPerformance.c
*
* Created on: Aug 24, 2011
* Author: sears
*/
#include <stasis/common.h>
#include <stasis/util/hash.h>
#include <stasis/util/time.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
2012-12-01 02:29:28 +00:00
char * foo = stasis_calloc(1024*1024*1024,char);
struct timeval start, stop;
gettimeofday(&start, 0);
for(long i = 0; i < (1024*1024*1024/sizeof(long)); i++) {
((long*)foo)[i] = i;
}
gettimeofday(&stop, 0);
double elapsed = stasis_timeval_to_double(stasis_subtract_timeval(stop, start));
printf("Took %f seconds to write to 1GB (%f mb/sec)\n", elapsed, (1024.0)/elapsed);
long len = 1;
for(long i = 0; i < 31; i++) {
gettimeofday(&start, 0);
stasis_crc32(foo, len, 0);
gettimeofday(&stop, 0);
elapsed = stasis_timeval_to_double(stasis_subtract_timeval(stop, start));
printf("Took %f seconds to checksum %ld bytes (%f mb/sec)\n", elapsed, len, ((double)len)/((1024.0*1024.0)*elapsed));
len *=2;
}
}