Commit 7a7f63a8 authored by william's avatar william

remove main from bench.c and fix typo in makefile

parent ff505515
......@@ -34,7 +34,7 @@ else
SOFLAGS = -shared
endif
ifeq ($(shell -uname -s), Linux)
ifeq ($(shell uname -s), Linux)
LIBS = -lrt
endif
......
......@@ -199,137 +199,3 @@ int luaopen_bench(lua_State *L) {
return 1;
} /* luaopen_bench() */
#if 0
int main(int argc, char **argv) {
extern char *optarg;
extern int optind;
int optc;
struct vops *vops;
char cmd[256];
struct op op;
setlocale(LC_ALL, "C");
while (-1 != (optc = getopt(argc, argv, SHORT_OPTS))) {
switch (optc) {
case 'n':
MAIN.count = strtoul(optarg, NULL, 0);
break;
case 't':
MAIN.maximum = (strtod(optarg, NULL) * TIMEOUT_mHZ);
break;
case 'v':
MAIN.verbose++;
break;
case 'h':
usage(stdout);
return 0;
default:
usage(stderr);
return 1;
} /* switch() */
} /* while() */
argv += optind;
argc -= optind;
if (argc > 0) {
MAIN.path = *argv++;
--argc;
}
if (!MAIN.verbose)
setvbuf(stdout, NULL, _IOFBF, 0);
if (!(MAIN.timeout = calloc(MAIN.count, sizeof *MAIN.timeout)))
err(1, "calloc");
if (!(MAIN.solib = dlopen(MAIN.path, RTLD_NOW|RTLD_LOCAL)))
errx(1, "%s: %s", MAIN.path, dlerror());
if (!(vops = dlsym(MAIN.solib, "VOPS")))
errx(1, "%s: %s", MAIN.path, dlerror());
MAIN.vops = *vops;
MAIN.vops.init(MAIN.timeout, MAIN.count, MAIN.verbose);
while (fgets(cmd, sizeof cmd, stdin) && parseop(&op, cmd)) {
struct timeout *to;
unsigned n;
switch (op.type) {
case OP_QUIT:
goto quit;
case OP_HELP:
usage(stdout);
break;
case OP_ADD:
to = &MAIN.timeout[op.add.id];
MAIN.vops.add(to, op.add.timeout);
break;
case OP_DEL:
to = &MAIN.timeout[op.del.id];
MAIN.vops.del(to);
break;
case OP_GET:
n = 0;
while ((to = MAIN.vops.get())) {
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;
MAIN.vops.update(MAIN.curtime);
break;
case OP_UPDATE:
MAIN.curtime = op.update.time;
MAIN.vops.update(MAIN.curtime);
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, arc4random_uniform(MAIN.maximum));
//MAIN.vops.add(to, random() % MAIN.maximum);
}
break;
case OP_TIME:
printf("clock %ld\n", clock());
break;
case OP_NONE:
break;
case OP_OOPS:
errx(1, "oops: %s", op.oops.why);
break;
}
} /* while() */
quit:
return 0;
} /* main() */
#endif
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