From patchwork Mon Jul 25 20:04:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 106747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AD59EB6FF5 for ; Tue, 26 Jul 2011 06:05:17 +1000 (EST) Received: from localhost ([::1]:49928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlROi-0005fQ-Oj for incoming@patchwork.ozlabs.org; Mon, 25 Jul 2011 16:05:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlRO2-0003cl-Tv for qemu-devel@nongnu.org; Mon, 25 Jul 2011 16:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlRNx-0001zA-Jl for qemu-devel@nongnu.org; Mon, 25 Jul 2011 16:04:22 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:40693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlRNx-0001yr-AG for qemu-devel@nongnu.org; Mon, 25 Jul 2011 16:04:17 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p6PK4GDx030777 for ; Mon, 25 Jul 2011 20:04:16 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6PK4GoI2617482 for ; Mon, 25 Jul 2011 21:04:16 +0100 Received: from d06av07.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6PK4G92024135 for ; Mon, 25 Jul 2011 14:04:16 -0600 Received: from stefanha-thinkpad.ibm.com (sig-9-146-145-232.uk.ibm.com [9.146.145.232]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6PK4BpV024030; Mon, 25 Jul 2011 14:04:15 -0600 From: Stefan Hajnoczi To: Date: Mon, 25 Jul 2011 21:04:10 +0100 Message-Id: <1311624250-1670-5-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1311624250-1670-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1311624250-1670-1-git-send-email-stefanha@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 194.196.100.162 Cc: Kevin Wolf , Blue Swirl , Anthony Liguori , Venkateswararao Jujjuri , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v7 4/4] coroutine: add test-coroutine --benchmark-lifecycle X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 test-coroutine ./test-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(); }