Commit c8319ee2 authored by william's avatar william

add some more benchmark ops

parent 9bee384b
...@@ -81,6 +81,7 @@ struct op *parseop(struct op *op, char *ln) { ...@@ -81,6 +81,7 @@ struct op *parseop(struct op *op, char *ln) {
break; break;
case 'g': /* get */ case 'g': /* get */
op->type = OP_GET; op->type = OP_GET;
op->get.verbose = (argc > 1)? strtol(arg[1], NULL, 0) : 0;
break; break;
case 's': /* step */ case 's': /* step */
...@@ -102,6 +103,16 @@ struct op *parseop(struct op *op, char *ln) { ...@@ -102,6 +103,16 @@ struct op *parseop(struct op *op, char *ln) {
case 'c': /* check */ case 'c': /* check */
op->type = OP_CHECK; op->type = OP_CHECK;
break;
case 'f': /* fill */
op->type = OP_FILL;
break;
case '#':
/* FALL THROUGH */
case 'n':
op->type = OP_NONE;
break; break;
default: default:
op->type = OP_OOPS; op->type = OP_OOPS;
...@@ -183,9 +194,11 @@ int main(int argc, char **argv) { ...@@ -183,9 +194,11 @@ int main(int argc, char **argv) {
errx(1, "%s: %s", MAIN.path, dlerror()); errx(1, "%s: %s", MAIN.path, dlerror());
MAIN.vops = *vops; MAIN.vops = *vops;
MAIN.vops.init(MAIN.timeout, MAIN.count);
while (fgets(cmd, sizeof cmd, stdin) && parseop(&op, cmd)) { while (fgets(cmd, sizeof cmd, stdin) && parseop(&op, cmd)) {
struct timeout *to; struct timeout *to;
unsigned n;
switch (op.type) { switch (op.type) {
case OP_QUIT: case OP_QUIT:
...@@ -205,10 +218,17 @@ int main(int argc, char **argv) { ...@@ -205,10 +218,17 @@ int main(int argc, char **argv) {
break; break;
case OP_GET: case OP_GET:
n = 0;
while ((to = MAIN.vops.get())) { while ((to = MAIN.vops.get())) {
printf("%ld expired", to - MAIN.timeout); if (op.get.verbose > 1)
printf("#%ld expired (%llu >= %llu)\n", to - MAIN.timeout, to->expires, MAIN.curtime);
n++;
} }
if (op.get.verbose)
printf("expired %u\n", n);
break; break;
case OP_STEP: case OP_STEP:
MAIN.curtime += op.step.time; MAIN.curtime += op.step.time;
...@@ -221,6 +241,16 @@ int main(int argc, char **argv) { ...@@ -221,6 +241,16 @@ int main(int argc, char **argv) {
break; break;
case OP_CHECK: case OP_CHECK:
MAIN.vops.check();
break;
case OP_FILL:
for (to = MAIN.timeout; to < &MAIN.timeout[MAIN.count]; to++) {
MAIN.vops.add(to, random() % MAIN.maximum);
}
break;
case OP_NONE:
break; break;
case OP_OOPS: case OP_OOPS:
errx(1, "oops: %s", op.oops.why); errx(1, "oops: %s", op.oops.why);
......
...@@ -10,6 +10,8 @@ struct op { ...@@ -10,6 +10,8 @@ struct op {
OP_STEP, OP_STEP,
OP_UPDATE, OP_UPDATE,
OP_CHECK, OP_CHECK,
OP_FILL,
OP_NONE,
} type; } type;
union { union {
...@@ -26,6 +28,10 @@ struct op { ...@@ -26,6 +28,10 @@ struct op {
unsigned id; unsigned id;
} del; } del;
struct {
int verbose;
} get;
struct { struct {
timeout_t time; timeout_t time;
} step, update; } step, update;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment