Newer
Older
res = test_performance(test, type, copt);
}
George Joseph
committed
ast_test_status_update(test, "%5.2fK traversals, %9s : %5lu ms\n",
iterations / 1000.0, test_container2str(type), (unsigned long)ast_tvdiff_ms(ast_tvnow(), start));
return res;
}
AST_TEST_DEFINE(astobj2_test_perf)
{
George Joseph
committed
/*!
* \brief The number of iteration of testloop to be performed.
* \note
* In order to keep the elapsed time sane, if AO2_DEBUG is defined in menuselect,
* only 25000 iterations are performed. Otherwise 100000.
*/
#ifdef AO2_DEBUG
#define ITERATIONS 25000
#else
#define ITERATIONS 100000
#endif
int res = AST_TEST_PASS;
switch (cmd) {
case TEST_INIT:
info->name = "astobj2_test_perf";
info->category = "/main/astobj2/perf/";
info->summary = "Test container performance";
info->description =
George Joseph
committed
"Runs container traversal tests.";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
}
George Joseph
committed
res = testloop(test, TEST_CONTAINER_LIST, 0, ITERATIONS);
if (!res) {
return res;
}
George Joseph
committed
res = testloop(test, TEST_CONTAINER_HASH, 0, ITERATIONS);
if (!res) {
return res;
}
George Joseph
committed
res = testloop(test, TEST_CONTAINER_RBTREE, 0, ITERATIONS);
return res;
}
static int unload_module(void)
{
AST_TEST_UNREGISTER(astobj2_test_1);
AST_TEST_UNREGISTER(astobj2_test_2);
AST_TEST_UNREGISTER(astobj2_test_4);
AST_TEST_UNREGISTER(astobj2_test_perf);
return 0;
}
static int load_module(void)
{
AST_TEST_REGISTER(astobj2_test_1);
AST_TEST_REGISTER(astobj2_test_2);
AST_TEST_REGISTER(astobj2_test_4);
AST_TEST_REGISTER(astobj2_test_perf);
return AST_MODULE_LOAD_SUCCESS;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ASTOBJ2 Unit Tests");