xxhash3 bench
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "xxhash.h"
|
||||
#include "addr_util.h"
|
||||
#include "osd_primary.h"
|
||||
#include "osd.h"
|
||||
@@ -15,8 +16,46 @@
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
|
||||
void xxhash_run_test(XXH3_state_t *st, void *buf, size_t size)
|
||||
{
|
||||
timespec tv, tv1;
|
||||
clock_gettime(CLOCK_REALTIME, &tv);
|
||||
uint64_t res = 1;
|
||||
uint64_t done = 0;
|
||||
while (true)
|
||||
{
|
||||
XXH3_64bits_reset(st);
|
||||
XXH3_64bits_update(st, buf, size);
|
||||
res *= XXH3_64bits_digest(st);
|
||||
done++;
|
||||
if (!(done % 100000))
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &tv1);
|
||||
if ((tv1.tv_sec-tv.tv_sec)*1000 + (tv1.tv_nsec-tv.tv_nsec)/1000000 > 1000)
|
||||
break;
|
||||
}
|
||||
}
|
||||
double sec = (tv1.tv_sec-tv.tv_sec) + (tv1.tv_nsec-tv.tv_nsec)/1000000000.0;
|
||||
fprintf(stderr, "xxhash3: %lu %zu byte blocks in %.2f sec = %.1f MB/s\n",
|
||||
done, size, sec, done*size/sec/1024/1024);
|
||||
}
|
||||
|
||||
void xxhash_bench()
|
||||
{
|
||||
std::vector<uint8_t> buf;
|
||||
buf.resize(128*1024);
|
||||
for (size_t i = 0; i < buf.size(); i++)
|
||||
buf[i] = ((i+37)*3) % 255;
|
||||
XXH3_state_t *st = XXH3_createState();
|
||||
xxhash_run_test(st, buf.data(), 4096);
|
||||
xxhash_run_test(st, buf.data(), buf.size());
|
||||
XXH3_freeState(st);
|
||||
}
|
||||
|
||||
osd_t::osd_t(const json11::Json & config, ring_loop_t *ringloop)
|
||||
{
|
||||
xxhash_bench();
|
||||
|
||||
zero_buffer_size = 1<<20;
|
||||
zero_buffer = malloc_or_die(zero_buffer_size);
|
||||
memset(zero_buffer, 0, zero_buffer_size);
|
||||
|
||||
Reference in New Issue
Block a user