From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVrYR-0003E9-Ce for qemu-devel@nongnu.org; Sun, 12 Jun 2011 16:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QVrYK-0007fQ-Sz for qemu-devel@nongnu.org; Sun, 12 Jun 2011 16:46:42 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:33706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVrYK-0007ex-Ek for qemu-devel@nongnu.org; Sun, 12 Jun 2011 16:46:36 -0400 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p5CKkYNU019199 for ; Sun, 12 Jun 2011 20:46:34 GMT Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5CKkTv12613428 for ; Sun, 12 Jun 2011 21:46:34 +0100 Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5CKkTua005156 for ; Sun, 12 Jun 2011 14:46:29 -0600 From: Stefan Hajnoczi Date: Sun, 12 Jun 2011 21:46:25 +0100 Message-Id: <1307911585-22106-6-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1307911585-22106-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1307911585-22106-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v5 5/5] coroutine: add check-coroutine --benchmark-lifecycle List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , Blue Swirl , "Aneesh Kumar K.V" , Paolo Bonzini , Venkateswararao Jujjuri Add a microbenchmark for coroutine create, enter, and return (aka lifecycle). This is a useful benchmark because users are expected to create many coroutines, one per I/O request for example, and we therefore need to provide good performance in that scenario. To run: make check-coroutine ./check-coroutine --benchmark-lifecycle 20000000 This will do 20,000,000 coroutine create, enter, return iterations and print the resulting time. Signed-off-by: Stefan Hajnoczi --- test-coroutine.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/test-coroutine.c b/test-coroutine.c index 9e9d3c9..bf9f3e9 100644 --- a/test-coroutine.c +++ b/test-coroutine.c @@ -150,6 +150,33 @@ static void test_lifecycle(void) g_assert(done); /* expect done to be true (second time) */ } +/* + * Lifecycle benchmark + */ + +static void coroutine_fn empty_coroutine(void *opaque) +{ + /* Do nothing */ +} + +static void perf_lifecycle(void) +{ + Coroutine *coroutine; + unsigned int i, max; + double duration; + + max = 1000000; + + g_test_timer_start(); + for (i = 0; i < max; i++) { + coroutine = qemu_coroutine_create(empty_coroutine); + qemu_coroutine_enter(coroutine, NULL); + } + duration = g_test_timer_elapsed(); + + g_test_message("Lifecycle %u iterations: %f s\n", max, duration); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -158,5 +185,8 @@ int main(int argc, char **argv) g_test_add_func("/basic/nesting", test_nesting); g_test_add_func("/basic/self", test_self); g_test_add_func("/basic/in_coroutine", test_in_coroutine); + if (g_test_perf()) { + g_test_add_func("/perf/lifecycle", perf_lifecycle); + } return g_test_run(); } -- 1.7.5.3