From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S76za-0001D7-ES for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:17:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S76zM-0005RY-BF for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:16:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S76zM-0005RH-39 for qemu-devel@nongnu.org; Mon, 12 Mar 2012 11:16:44 -0400 From: Kevin Wolf Date: Mon, 12 Mar 2012 16:19:51 +0100 Message-Id: <1331565591-8414-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1331565591-8414-1-git-send-email-kwolf@redhat.com> References: <1331565591-8414-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 20/20] test-coroutine: add performance test for nesting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Alex Barcelo The performance test will also check for nesting. It will do a certain quantity of cycles, and each of one will do a depth nesting process. This is useful for benchmarking the creation of coroutines, given that nesting is creation-intensive (and the other perf test does not benchmark that). Signed-off-by: Alex Barcelo Signed-off-by: Kevin Wolf --- test-coroutine.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/test-coroutine.c b/test-coroutine.c index bf9f3e9..e5d14eb 100644 --- a/test-coroutine.c +++ b/test-coroutine.c @@ -177,6 +177,32 @@ static void perf_lifecycle(void) g_test_message("Lifecycle %u iterations: %f s\n", max, duration); } +static void perf_nesting(void) +{ + unsigned int i, maxcycles, maxnesting; + double duration; + + maxcycles = 100000000; + maxnesting = 20000; + Coroutine *root; + NestData nd = { + .n_enter = 0, + .n_return = 0, + .max = maxnesting, + }; + + g_test_timer_start(); + for (i = 0; i < maxcycles; i++) { + root = qemu_coroutine_create(nest); + qemu_coroutine_enter(root, &nd); + } + duration = g_test_timer_elapsed(); + + g_test_message("Nesting %u iterations of %u depth each: %f s\n", + maxcycles, maxnesting, duration); +} + + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -187,6 +213,7 @@ int main(int argc, char **argv) g_test_add_func("/basic/in_coroutine", test_in_coroutine); if (g_test_perf()) { g_test_add_func("/perf/lifecycle", perf_lifecycle); + g_test_add_func("/perf/nesting", perf_nesting); } return g_test_run(); } -- 1.7.6.5