2011-08-31 18:07:38 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
2011-08-31 18:07:38 +00:00
|
|
|
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);
|
|
|
|
|
2011-09-26 00:34:33 +00:00
|
|
|
long len = 1;
|
|
|
|
for(long i = 0; i < 31; i++) {
|
|
|
|
gettimeofday(&start, 0);
|
|
|
|
stasis_crc32(foo, len, 0);
|
|
|
|
gettimeofday(&stop, 0);
|
2011-08-31 18:07:38 +00:00
|
|
|
|
2011-09-26 00:34:33 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-08-31 18:07:38 +00:00
|
|
|
}
|