Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- typedef unsigned int uint32;
- #include "pg_crc.h"
- #include "fnv.h"
- #include "xxhash.h"
- #define VALUES 2000000000
- void main() {
- int i;
- int result = FNV0_32_INIT;
- void * state;
- struct timeval start, end;
- gettimeofday(&start, NULL);
- for (i = 0; i < VALUES; i++) {
- result = fnv_32_buf(&i, 4, result);
- }
- gettimeofday(&end, NULL);
- printf("FNV duration = %.3f\n", (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0);
- gettimeofday(&start, NULL);
- for (i = 0; i < VALUES; i++) {
- result = fnv_32a_buf(&i, 4, result);
- }
- gettimeofday(&end, NULL);
- printf("FNVa duration = %.3f\n", (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0);
- gettimeofday(&start, NULL);
- for (i = 0; i < VALUES; i++) {
- result = jenkins_one_at_a_time_hash(&i, 4);
- }
- gettimeofday(&end, NULL);
- printf("jenkins duration = %.3f\n", (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0);
- gettimeofday(&start, NULL);
- for (i = 0; i < VALUES; i++) {
- INIT_CRC32(result);
- COMP_CRC32(result, &i, 4);
- FIN_CRC32(result);
- }
- gettimeofday(&end, NULL);
- printf("crc32 duration = %.3f\n", (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0);
- gettimeofday(&start, NULL);
- for (i = 0; i < VALUES; i++) {
- state = XXH32_init(result);
- XXH32_update(state, &i, 4);
- XXH32_digest(state);
- }
- gettimeofday(&end, NULL);
- printf("xxhash duration = %.3f\n", (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment