#include "postgres.h" #include #include #include "pg_crc.h" int main() { char buffer[TESTSIZE]; pg_crc32 mycrc[2]; int j; struct timeval tstart; struct timeval tstop; srand(time(NULL)); for (j = 0; j < TESTSIZE; ++j) buffer[j] = (char) (255 * (rand() / (RAND_MAX + 1.0))); gettimeofday(&tstart, NULL); for (j = 0; j < NTESTS; j++) { INIT_CRC32(mycrc[j&1]); COMP_CRC32(mycrc[j&1], buffer, TESTSIZE); FIN_CRC32(mycrc[j&1]); } gettimeofday(&tstop, NULL); if (tstop.tv_usec < tstart.tv_usec) { tstop.tv_sec--; tstop.tv_usec += 1000000; } printf("bufsize = %d, loops = %d, elapsed = %ld.%06ld\n", TESTSIZE, NTESTS, (long) (tstop.tv_sec - tstart.tv_sec), (long) (tstop.tv_usec - tstart.tv_usec)); return 0; }