#include "../fio.h"
#include "../gettime.h"
-#include "../time.h"
+#include "../fio_time.h"
#include "../verify.h"
#include "../crc/md5.h"
#include "../crc/sha1.h"
#include "../crc/sha256.h"
#include "../crc/sha512.h"
+#include "../crc/xxhash.h"
-#define CHUNK 131072
-#define NR_CHUNKS 2048
+#include "test.h"
+
+#define CHUNK 131072U
+#define NR_CHUNKS 2048U
struct test_type {
const char *name;
T_SHA1 = 1U << 6,
T_SHA256 = 1U << 7,
T_SHA512 = 1U << 8,
+ T_XXHASH = 1U << 9,
};
static void randomize_buf(void *buf, unsigned int size, int seed)
return ret;
}
+static uint64_t t_xxhash(void)
+{
+ void *state;
+ struct timeval s;
+ uint64_t ret;
+ void *buf;
+ int i;
+
+ state = XXH32_init(0x8989);
+
+ buf = malloc(CHUNK);
+ randomize_buf(buf, CHUNK, 0x8989);
+
+ fio_gettime(&s, NULL);
+ for (i = 0; i < NR_CHUNKS; i++)
+ XXH32_update(state, buf, CHUNK);
+
+ XXH32_digest(state);
+ ret = utime_since_now(&s);
+ free(buf);
+ return ret;
+}
+
static struct test_type t[] = {
{
.name = "md5",
.mask = T_SHA512,
.fn = t_sha512,
},
+ {
+ .name = "xxhash",
+ .mask = T_XXHASH,
+ .fn = t_xxhash,
+ },
{
.name = NULL,
},
mask = 0;
while ((name = strsep(&str, ",")) != NULL) {
for (i = 0; t[i].name; i++) {
- if (!strncmp(t[i].name, name, strlen(t[i].name))) {
+ if (!strcmp(t[i].name, name)) {
mask |= t[i].mask;
break;
}
return mask;
}
+static int list_types(void)
+{
+ int i;
+
+ for (i = 0; t[i].name; i++)
+ printf("%s\n", t[i].name);
+
+ return 0;
+}
+
int fio_crctest(const char *type)
{
unsigned int test_mask = 0;
if (!type)
test_mask = ~0U;
+ else if (!strcmp(type, "help") || !strcmp(type, "list"))
+ return list_types();
else
test_mask = get_test_mask(type);
usec = t[i].fn();
mb_sec = (double) mb / (double) usec;
mb_sec /= (1.024 * 1.024);
- printf("%s:\t%.2f MB/sec\n", t[i].name, mb_sec);
+ printf("%s:\t%8.2f MB/sec\n", t[i].name, mb_sec);
}
+
return 0;
}