[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/29] coroutine: add test-coroutine --benchmark-lif
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 19/29] coroutine: add test-coroutine --benchmark-lifecycle |
Date: |
Wed, 3 Aug 2011 16:14:14 +0200 |
From: Stefan Hajnoczi <address@hidden>
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 <address@hidden>
---
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.6
- [Qemu-devel] [PATCH 12/29] scsi-disk: Remove 'drive_kind', (continued)
- [Qemu-devel] [PATCH 12/29] scsi-disk: Remove 'drive_kind', Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 11/29] scsi: Sanitize command definitions, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 08/29] scsi-disk: Codingstyle fixes, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 13/29] block: Removed unused function bdrv_write_sync, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 14/29] raw-posix: Typo fix, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 10/29] scsi: Remove REZERO_UNIT emulation, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 15/29] raw-posix: Always check paio_init result, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 18/29] coroutine: add test-coroutine automated tests, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 16/29] coroutine: introduce coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 22/29] block: Add bdrv_co_readv/writev emulation, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 19/29] coroutine: add test-coroutine --benchmark-lifecycle,
Kevin Wolf <=
- [Qemu-devel] [PATCH 20/29] block: Add bdrv_co_readv/writev, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 21/29] block: Emulate AIO functions with bdrv_co_readv/writev, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 29/29] block: Use bdrv_co_* instead of synchronous versions in coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 28/29] posix-aio-compat: Allow read after EOF, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 23/29] coroutines: Locks, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 17/29] coroutine: implement coroutines using gthread, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 25/29] qcow: Use coroutines, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 26/29] async: Remove AsyncContext, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 27/29] coroutines: Use one global bottom half for CoQueue, Kevin Wolf, 2011/08/03
- [Qemu-devel] [PATCH 24/29] qcow2: Use coroutines, Kevin Wolf, 2011/08/03