diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-23 15:12:34 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-03-26 13:05:03 +0100 |
commit | 3e5ad834d770909642b70589d24c6b7a4103048e (patch) | |
tree | eb8485d733dfb931c8c1b71513e0fe6ce2041db8 | |
parent | d91f0eb67e2226d118af4874e069dac59652bd2a (diff) |
Add benchmark for context switching.
-rw-r--r-- | tests/benchmarks/benchmarks.cpp | 29 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 3 | ||||
-rw-r--r-- | tests/tests.pro | 2 |
3 files changed, 33 insertions, 1 deletions
diff --git a/tests/benchmarks/benchmarks.cpp b/tests/benchmarks/benchmarks.cpp new file mode 100644 index 0000000..a02c458 --- /dev/null +++ b/tests/benchmarks/benchmarks.cpp @@ -0,0 +1,29 @@ +#include <QtTest/QtTest> +#include <coroutine.h> + +class benchmark : public QObject +{ + Q_OBJECT +private slots: + void switchToCoroutineAndBack(); +}; + +static void yielder() +{ + forever + Coroutine::yield(); +} + +void benchmark::switchToCoroutineAndBack() +{ + Coroutine *c = Coroutine::build(&yielder); + c->createStack(); + QBENCHMARK { + c->cont(); + } + delete c; +} + +QTEST_MAIN(benchmark) + +#include "benchmarks.moc" diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro new file mode 100644 index 0000000..59b6bbe --- /dev/null +++ b/tests/benchmarks/benchmarks.pro @@ -0,0 +1,3 @@ +QT += testlib +SOURCES += benchmarks.cpp +include(../../use_coroutine.pri) diff --git a/tests/tests.pro b/tests/tests.pro index 7fbc8a9..6b6bdac 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = auto +SUBDIRS = auto benchmarks |