-
Notifications
You must be signed in to change notification settings - Fork 0
/
testutil.h
73 lines (64 loc) · 2.04 KB
/
testutil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdbool.h>
#include <pthread.h>
/*
* No error check wrapper functions
*/
void die(const char *err, ...);
void *xmalloc(size_t size);
void xpthread_create(pthread_t *thread, void *(*routine)(void *), void *arg);
void xpthread_join(pthread_t th);
/*
* Key generator library
*/
#define KEYGEN_KEY_SIZE sizeof("0x0000000000000000-0x0000000000000000")
#define KEYGEN_PREFIX_SIZE (sizeof("0x0000000000000000-") - 1)
struct keygen {
unsigned int prefix;
char key[KEYGEN_KEY_SIZE];
unsigned int (*next)(unsigned int *state);
unsigned int seed;
};
char *keygen_next_key(struct keygen *keygen);
char *keygen_prefix(struct keygen *keygen, char *buf);
void keygen_set_generator(const char *generator);
void keygen_init(struct keygen *keygen, unsigned int seed);
/*
* Benchmark utilities
*/
struct benchmark_config;
struct benchmark_operations {
void *(*open_db)(struct benchmark_config *config);
void (*close_db)(void *db);
void (*put_test)(void *db, int num, int vsiz, unsigned int seed);
void (*get_test)(void *db, int num, int vsiz, unsigned int seed);
void (*putlist_test)(void *db, const char *command, int num, int vsiz,
int batch, unsigned int seed);
void (*fwmkeys_test)(void *db, int num, unsigned int seed);
void (*getlist_test)(void *db, const char *command, int num, int vsiz,
int batch, unsigned int seed);
void (*range_test)(void *db, const char *command, int num, int vsiz,
int batch, unsigned int seed);
void (*rangeout_test)(void *db, const char *command, int num, int vsiz,
int batch, unsigned int seed);
void (*outlist_test)(void *db, const char *command, int num, int batch,
unsigned int seed);
};
struct benchmark_config {
const char *producer;
const char *consumer;
const char *host;
const char *path;
int port;
int num;
int vsiz;
unsigned int seed_offset;
int batch;
int producer_thnum;
int consumer_thnum;
int num_works;
bool debug;
int verbose;
struct benchmark_operations ops;
};
void parse_options(struct benchmark_config *config, int argc, char **argv);
void benchmark(struct benchmark_config *config);