diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-19 18:30:49 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-19 18:30:49 +0000 |
commit | 50aa5b08d186be73c92a9c3494505b8833def7c1 (patch) | |
tree | c3bebcbf75074329e07a179a74f4d9b0daa19bad /main | |
parent | ab6a6c0cf07f19ca93d5ce72475990d5fff5833d (diff) |
- Make res_timing_pthread allow a max rate of 100/sec instead of 50/sec
- change the "timing test" CLI command to let you specify a timing rate to test
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@124023 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/timing.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/main/timing.c b/main/timing.c index e6b7c25c3..5f6023203 100644 --- a/main/timing.c +++ b/main/timing.c @@ -202,17 +202,33 @@ static char *timing_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args * { int fd, count = 0; struct timeval start, end; + unsigned int test_rate = 50; switch (cmd) { case CLI_INIT: e->command = "timing test"; - e->usage = "Usage: timing test\n"; + e->usage = "Usage: timing test <rate>\n" + " Test a timer with a specified rate, 100/sec by default.\n" + ""; return NULL; case CLI_GENERATE: return NULL; } - ast_cli(a->fd, "Attempting to test a timer with 50 ticks per second ...\n"); + if (a->argc != 2 && a->argc != 3) { + return CLI_SHOWUSAGE; + } + + if (a->argc == 3) { + unsigned int rate; + if (sscanf(a->argv[2], "%u", &rate) == 1) { + test_rate = rate; + } else { + ast_cli(a->fd, "Invalid rate '%s', using default of %u\n", a->argv[2], test_rate); + } + } + + ast_cli(a->fd, "Attempting to test a timer with %u ticks per second ...\n", test_rate); if ((fd = ast_timer_open()) == -1) { ast_cli(a->fd, "Failed to open timing fd\n"); @@ -221,7 +237,7 @@ static char *timing_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args * start = ast_tvnow(); - ast_timer_set_rate(fd, 50); + ast_timer_set_rate(fd, test_rate); while (ast_tvdiff_ms((end = ast_tvnow()), start) < 1000) { int res; |