From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHZXM-0007Dk-5r for qemu-devel@nongnu.org; Wed, 13 Aug 2014 10:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHZXH-00019W-7w for qemu-devel@nongnu.org; Wed, 13 Aug 2014 10:28:24 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:52639 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHZXH-00019O-25 for qemu-devel@nongnu.org; Wed, 13 Aug 2014 10:28:19 -0400 Date: Wed, 13 Aug 2014 16:27:29 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140813142729.GB3091@irqsave.net> References: <1407924527-32687-1-git-send-email-ming.lei@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1407924527-32687-1-git-send-email-ming.lei@canonical.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1] test-coroutine: test cost introduced by coroutine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Charlie Shepherd , Stefan Hajnoczi , Paolo Bonzini , Gabriel Kerneis The Wednesday 13 Aug 2014 =E0 18:08:47 (+0800), Ming Lei wrote : > This test runs dummy function with coroutine by using > two enter and one yield since which is a common usage. >=20 > So we can see the cost introduced by corouting for running > one function, for example: >=20 > Run operation 20000000 iterations 4.841071 s, 4131K operations/s > 242ns per coroutine >=20 > Signed-off-by: Ming Lei > --- > tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) >=20 > diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c > index 6e634f4..e22fae1 100644 > --- a/tests/test-coroutine.c > +++ b/tests/test-coroutine.c > @@ -311,6 +311,35 @@ static void perf_baseline(void) > maxcycles, duration); > } > =20 > +static __attribute__((noinline)) void perf_cost_func(void *opaque) > +{ > + qemu_coroutine_yield(); > +} > + > +static void perf_cost(void) > +{ > + const unsigned long maxcycles =3D 40000000; > + unsigned long i =3D 0; > + double duration; > + unsigned long ops; > + Coroutine *co; > + > + g_test_timer_start(); > + while (i++ < maxcycles) { > + co =3D qemu_coroutine_create(perf_cost_func); I am not sure qemu_coroutine_create is systematically used. I rather believe the code try to reuse existing coroutine. > + qemu_coroutine_enter(co, &i); > + qemu_coroutine_enter(co, NULL); > + } > + duration =3D g_test_timer_elapsed(); > + ops =3D (long)(maxcycles / (duration * 1000)); > + > + g_test_message("Run operation %lu iterations %f s, %luK operations= /s, " > + "%luns per coroutine", > + maxcycles, > + duration, ops, > + (unsigned long)(1000000000 * duration) / maxcycles)= ; > +} > + > int main(int argc, char **argv) > { > g_test_init(&argc, &argv, NULL); > @@ -325,6 +354,7 @@ int main(int argc, char **argv) > g_test_add_func("/perf/nesting", perf_nesting); > g_test_add_func("/perf/yield", perf_yield); > g_test_add_func("/perf/function-call", perf_baseline); > + g_test_add_func("/perf/cost", perf_cost); > } > return g_test_run(); > } > --=20 > 1.7.9.5 >=20 >=20