diff options
author | George Joseph <george.joseph@fairview5.com> | 2014-06-20 15:27:43 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2014-06-20 15:27:43 +0000 |
commit | 577632dec957bfec258918a381133a3c41411b37 (patch) | |
tree | 4eec13395db7c190e79cbedf3669b80fff4f98ea /tests/test_astobj2.c | |
parent | d87f8c429e6852d11f7a3bddf6981e2f754c1ea8 (diff) |
astobj2: Additional refactoring to push impl specific code down into the impls.
Move some implementation specific code from astobj2_container.c into
astobj2_hash.c and astobj2_rbtree.c. This completely removes the need for
astobj2_container to switch on RTTI and it no longer has any knowledge of
the implementation details.
Also adds AO2_DEBUG as a new compile option in menuselect which controls
astobj2 debugging independently of AST_DEVMODE and REF_DEBUG.
Tested by: George Joseph
Review: https://reviewboard.asterisk.org/r/3593/
........
Merged revisions 416806 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416807 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_astobj2.c')
-rw-r--r-- | tests/test_astobj2.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/test_astobj2.c b/tests/test_astobj2.c index 67e8e45bd..13ce7f994 100644 --- a/tests/test_astobj2.c +++ b/tests/test_astobj2.c @@ -1927,7 +1927,10 @@ AST_TEST_DEFINE(astobj2_test_4) static enum ast_test_result_state test_performance(struct ast_test *test, enum test_container_type type, unsigned int copt) { -#define OBJS 256 +/*! + * \brief The number of objects inserted and searched for in the container under test. + */ +#define OBJS 73 int res = AST_TEST_PASS; struct ao2_container *c1 = NULL; struct test_obj *tobj[OBJS]; @@ -1989,47 +1992,58 @@ test_cleanup: } static enum ast_test_result_state testloop(struct ast_test *test, - enum test_container_type type, int copt) + enum test_container_type type, int copt, int iterations) { -#define ITERATIONS 2500 int res = AST_TEST_PASS; int i; struct timeval start; start = ast_tvnow(); - for (i = 1 ; i <= ITERATIONS && res == AST_TEST_PASS ; i++) { + for (i = 1 ; i <= iterations && res == AST_TEST_PASS ; i++) { res = test_performance(test, type, copt); } - ast_test_status_update(test, "%dK traversals, %9s : %5lu ms\n", - ITERATIONS / 1000, test_container2str(type), (unsigned long)ast_tvdiff_ms(ast_tvnow(), start)); + 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) { +/*! + * \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/"; + info->category = "/main/astobj2/perf"; info->summary = "Test container performance"; info->description = - "Runs 100000 container traversal tests."; + "Runs container traversal tests."; return AST_TEST_NOT_RUN; case TEST_EXECUTE: break; } - res = testloop(test, TEST_CONTAINER_LIST, 0); + res = testloop(test, TEST_CONTAINER_LIST, 0, ITERATIONS); if (!res) { return res; } - res = testloop(test, TEST_CONTAINER_HASH, 0); + res = testloop(test, TEST_CONTAINER_HASH, 0, ITERATIONS); if (!res) { return res; } - res = testloop(test, TEST_CONTAINER_RBTREE, 0); + res = testloop(test, TEST_CONTAINER_RBTREE, 0, ITERATIONS); return res; } |