Commit adb6c374 authored by Pekka Pessi's avatar Pekka Pessi
Browse files

su_timer_test.c: added -N option.

darcs-hash:20060823131641-65a35-092563d814b89d26eaf79248e547a827ae7fb96d.gz
parent 327f59bb
...@@ -124,7 +124,7 @@ increment(struct tester *tester, su_timer_t *t, struct timing *ti) ...@@ -124,7 +124,7 @@ increment(struct tester *tester, su_timer_t *t, struct timing *ti)
void void
usage(char const *name) usage(char const *name)
{ {
fprintf(stderr, "usage: %s [-1r] [interval]\n", name); fprintf(stderr, "usage: %s [-1r] [-Nnum] [interval]\n", name);
exit(1); exit(1);
} }
...@@ -143,22 +143,30 @@ int main(int argc, char *argv[]) ...@@ -143,22 +143,30 @@ int main(int argc, char *argv[])
char *s; char *s;
int use_t1 = 0; int use_t1 = 0;
su_time_t now, started; su_time_t now, started;
intptr_t i, N; intptr_t i, N = 500;
struct timing timing[1] = {{ 0 }}; struct timing timing[1] = {{ 0 }};
struct tester tester[1] = {{ 0 }}; struct tester tester[1] = {{ 0 }};
while (argv[1] && argv[1][0] == '-') { while (argv[1] && argv[1][0] == '-') {
char *o = argv[1] + 1; char *o = argv[1] + 1;
while (*o) while (*o) {
if (*o == '1') if (*o == '1')
o++, use_t1 = 1; o++, use_t1 = 1;
else if (*o == 'r') else if (*o == 'r')
o++, timing->t_run = 1; o++, timing->t_run = 1;
else if (*o == 'N') {
if (o[1])
N = strtoul(o + 1, &o, 0);
else if (argv[2])
N = strtoul(argv++[2], &o, 0);
break;
}
else else
break; break;
if (o == argv[1] + 1) }
if (*o)
usage(argv0); usage(argv0);
argv++; argv++;
} }
...@@ -220,8 +228,8 @@ int main(int argc, char *argv[]) ...@@ -220,8 +228,8 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Insert 500 timers in order */ /* Insert timers in order */
timers = calloc(N = 500, sizeof *timers); timers = calloc(N, sizeof *timers);
if (!timers) { perror("calloc"); exit(1); } if (!timers) { perror("calloc"); exit(1); }
now = started = su_now(); now = started = su_now();
......
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