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) {
break;
case 'g': /* get */
op->type = OP_GET;
op->get.verbose = (argc > 1)? strtol(arg[1], NULL, 0) : 0;
break;
case 's': /* step */
......@@ -102,6 +103,16 @@ struct op *parseop(struct op *op, char *ln) {
case 'c': /* check */
op->type = OP_CHECK;
break;
case 'f': /* fill */
op->type = OP_FILL;
break;
case '#':
/* FALL THROUGH */
case 'n':
op->type = OP_NONE;
break;
default:
op->type = OP_OOPS;
......@@ -183,9 +194,11 @@ int main(int argc, char **argv) {
errx(1, "%s: %s", MAIN.path, dlerror());
MAIN.vops = *vops;
MAIN.vops.init(MAIN.timeout, MAIN.count);
while (fgets(cmd, sizeof cmd, stdin) && parseop(&op, cmd)) {
struct timeout *to;
unsigned n;
switch (op.type) {
case OP_QUIT:
......@@ -205,10 +218,17 @@ int main(int argc, char **argv) {
break;
case OP_GET:
n = 0;
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;
case OP_STEP:
MAIN.curtime += op.step.time;
......@@ -221,6 +241,16 @@ int main(int argc, char **argv) {
break;
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;
case OP_OOPS:
errx(1, "oops: %s", op.oops.why);
......
......@@ -10,6 +10,8 @@ struct op {
OP_STEP,
OP_UPDATE,
OP_CHECK,
OP_FILL,
OP_NONE,
} type;
union {
......@@ -26,6 +28,10 @@ struct op {
unsigned id;
} del;
struct {
int verbose;
} get;
struct {
timeout_t time;
} 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