Revision 35afde18 xseg/peers/user/bench-utils.c
b/xseg/peers/user/bench-utils.c | ||
---|---|---|
81 | 81 |
return num; |
82 | 82 |
} |
83 | 83 |
|
84 |
int read_insanity(char *insanity) |
|
85 |
{ |
|
86 |
if (strcmp(insanity, "sane") == 0) |
|
87 |
return TM_SANE; |
|
88 |
if (strcmp(insanity, "eccentric") == 0) |
|
89 |
return TM_ECCENTRIC; |
|
90 |
if (strcmp(insanity, "manic") == 0) |
|
91 |
return TM_MANIC; |
|
92 |
if (strcmp(insanity, "paranoid") == 0) |
|
93 |
return TM_PARANOID; |
|
94 |
return -1; |
|
95 |
} |
|
96 |
|
|
84 | 97 |
int read_op(char *op) |
85 | 98 |
{ |
86 | 99 |
if (strcmp(op, "read") == 0) |
... | ... | |
128 | 141 |
void create_target(struct bench *prefs, struct xseg_request *req, |
129 | 142 |
uint64_t new) |
130 | 143 |
{ |
131 |
struct xseg *xseg = prefs->xseg; |
|
144 |
struct xseg *xseg = prefs->peer->xseg;
|
|
132 | 145 |
char *req_target; |
133 | 146 |
|
134 | 147 |
req_target = xseg_get_target(xseg, req); |
135 | 148 |
|
136 | 149 |
if (prefs->op == X_READ || prefs->op == X_WRITE) |
137 | 150 |
new %= prefs->os; |
138 |
//FIXME: Include timestamp in target name |
|
139 |
snprintf(req_target, TARGETLEN, "bench-%10lu", new); |
|
151 |
//FIXME: Make it more elegant |
|
152 |
snprintf(req_target, TARGETLEN, "%s-%016lu", global_id, new); |
|
153 |
XSEGLOG2(&lc, D, "Target name of request %lu is %s\n", new, req_target); |
|
140 | 154 |
} |
141 | 155 |
|
142 | 156 |
void create_chunk(struct bench *prefs, struct xseg_request *req, uint64_t new) |
143 | 157 |
{ |
144 |
struct xseg *xseg = prefs->xseg; |
|
158 |
struct xseg *xseg = prefs->peer->xseg;
|
|
145 | 159 |
char *req_data; |
146 | 160 |
|
147 | 161 |
req_data = xseg_get_data(xseg, req); |
... | ... | |
150 | 164 |
|
151 | 165 |
uint64_t determine_next(struct bench *prefs) |
152 | 166 |
{ |
153 |
if (prefs->flag & PATTERN_FLAG == IO_SYNC)
|
|
167 |
if ((prefs->flags & PATTERN_FLAG) == IO_SYNC)
|
|
154 | 168 |
return prefs->sub_tm->completed + 1; |
155 | 169 |
else { |
156 |
//Randomly choose
|
|
170 |
return lfsr_next(prefs->lfsr);
|
|
157 | 171 |
} |
158 | 172 |
} |
159 | 173 |
|
174 |
//FIXME: this looks like a hack, handle it more elegantly |
|
175 |
void create_id() |
|
176 |
{ |
|
177 |
struct timespec seed; |
|
178 |
|
|
179 |
clock_gettime(CLOCK_MONOTONIC_RAW, &seed); |
|
180 |
|
|
181 |
global_seed = seed.tv_nsec; |
|
182 |
//nanoseconds can't be more than 9 digits |
|
183 |
snprintf(global_id, IDLEN, "bench-%09lu", global_seed); |
|
184 |
XSEGLOG2(&lc, I, "Global ID is %s\n", global_id); |
|
185 |
} |
Also available in: Unified diff