[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/29] test-coroutine: test cost introduced by corout
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/29] test-coroutine: test cost introduced by coroutine |
Date: |
Fri, 22 Aug 2014 16:51:35 +0200 |
From: Ming Lei <address@hidden>
This test runs dummy function with coroutine by using
two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running
one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s
242ns per coroutine
Signed-off-by: Ming Lei <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
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);
}
+static __attribute__((noinline)) void perf_cost_func(void *opaque)
+{
+ qemu_coroutine_yield();
+}
+
+static void perf_cost(void)
+{
+ const unsigned long maxcycles = 40000000;
+ unsigned long i = 0;
+ double duration;
+ unsigned long ops;
+ Coroutine *co;
+
+ g_test_timer_start();
+ while (i++ < maxcycles) {
+ co = qemu_coroutine_create(perf_cost_func);
+ qemu_coroutine_enter(co, &i);
+ qemu_coroutine_enter(co, NULL);
+ }
+ duration = g_test_timer_elapsed();
+ ops = (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();
}
--
1.8.3.1
- [Qemu-devel] [PULL 03/29] qemu-io-cmds: g_renew() can't fail, bury dead error handling, (continued)
- [Qemu-devel] [PULL 03/29] qemu-io-cmds: g_renew() can't fail, bury dead error handling, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 02/29] block: Use g_new() & friends to avoid multiplying sizes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 01/29] block: Use g_new() & friends where that makes obvious sense, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 05/29] runner: Add an argument for test duration, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 04/29] block: Drop some superfluous casts from void *, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 06/29] runner: Kill a program under test by time-out, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 08/29] qcow2: Use g_try_new0() for cache array, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 07/29] qcow2: Constant cache size in bytes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 10/29] iotests: Add test for qcow2's cache options, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 09/29] qcow2: Add runtime options for cache sizes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 11/29] test-coroutine: test cost introduced by coroutine,
Kevin Wolf <=
- [Qemu-devel] [PULL 12/29] qemu-iotests: Fix 028 reference output for qed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 14/29] virtio-blk: allow block_resize with dataplane, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 15/29] virtio-blk: fix reference a pointer which might be freed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 17/29] blkdebug: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 18/29] blkverify: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 21/29] iotests: Add test for image filename construction, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 22/29] block/vvfat.c: remove debugging code to reinit stderr if NULL, Kevin Wolf, 2014/08/22