[asterisk-commits] russell: branch russell/heap r175772 - /team/russell/heap/tests/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 14 11:59:32 CST 2009
Author: russell
Date: Sat Feb 14 11:59:32 2009
New Revision: 175772
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=175772
Log:
Don't hard code 1 million in the add test, add skeleton for del test
Modified:
team/russell/heap/tests/test_heap.c
team/russell/heap/tests/test_sched.c
Modified: team/russell/heap/tests/test_heap.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/heap/tests/test_heap.c?view=diff&rev=175772&r1=175771&r2=175772
==============================================================================
--- team/russell/heap/tests/test_heap.c (original)
+++ team/russell/heap/tests/test_heap.c Sat Feb 14 11:59:32 2009
@@ -175,10 +175,16 @@
switch (cmd) {
case CLI_INIT:
e->command = "heap test";
- e->usage = "";
+ e->usage = ""
+ "Usage: heap test\n"
+ "";
return NULL;
case CLI_GENERATE:
return NULL;
+ }
+
+ if (a->argc != e->args) {
+ return CLI_SHOWUSAGE;
}
if ((res = test1(a->fd))) {
Modified: team/russell/heap/tests/test_sched.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/heap/tests/test_sched.c?view=diff&rev=175772&r1=175771&r2=175772
==============================================================================
--- team/russell/heap/tests/test_sched.c (original)
+++ team/russell/heap/tests/test_sched.c Sat Feb 14 11:59:32 2009
@@ -41,20 +41,29 @@
{
struct sched_context *con;
struct timeval start;
- static const unsigned int one_million = 1000000;
- unsigned int i = one_million;
+ unsigned int i;
switch (cmd) {
case CLI_INIT:
e->command = "sched test add";
- e->usage = "";
+ e->usage = ""
+ "Usage: sched test add <num>\n"
+ "";
return NULL;
case CLI_GENERATE:
return NULL;
}
+ if (a->argc != e->args + 1) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (sscanf(a->argv[e->args], "%u", &i) != 1) {
+ return CLI_SHOWUSAGE;
+ }
+
ast_cli(a->fd, "Testing ast_sched_add() performance - timing how long it takes "
- "to add a million entries at random time intervals from 0 to 60 seconds\n");
+ "to add %u entries at random time intervals from 0 to 60 seconds\n", i);
if (!(con = sched_context_create())) {
ast_cli(a->fd, "Test failed - could not create scheduler context\n");
@@ -79,8 +88,53 @@
return CLI_SUCCESS;
}
+static char *handle_cli_sched_test_del(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct sched_context *con;
+ struct timeval start;
+ unsigned int i;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "sched test del";
+ e->usage = ""
+ "Usage: sched test del <num>\n"
+ "";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != e->args + 1) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (sscanf(a->argv[e->args], "%u", &i) != 1) {
+ return CLI_SHOWUSAGE;
+ }
+
+ ast_cli(a->fd, "Testing ast_sched_del() performance - timing how long it takes "
+ "to delete %u entries with random time intervals from 0 to 60 seconds\n", i);
+
+ if (!(con = sched_context_create())) {
+ ast_cli(a->fd, "Test failed - could not create scheduler context\n");
+ return CLI_FAILURE;
+ }
+
+ start = ast_tvnow();
+
+ /* Stuff goes here. */
+
+ ast_cli(a->fd, "Test complete - %d ms\n", ast_tvdiff_ms(ast_tvnow(), start));
+
+ sched_context_destroy(con);
+
+ return CLI_SUCCESS;
+}
+
static struct ast_cli_entry cli_sched[] = {
AST_CLI_DEFINE(handle_cli_sched_test_add, "Test ast_sched_add performance"),
+ AST_CLI_DEFINE(handle_cli_sched_test_del, "Test ast_sched_del performance"),
};
static int unload_module(void)
More information about the asterisk-commits
mailing list