summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/benchmarks.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-03-23 15:12:34 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2010-03-26 13:05:03 +0100
commit3e5ad834d770909642b70589d24c6b7a4103048e (patch)
treeeb8485d733dfb931c8c1b71513e0fe6ce2041db8 /tests/benchmarks/benchmarks.cpp
parentd91f0eb67e2226d118af4874e069dac59652bd2a (diff)
Add benchmark for context switching.
Diffstat (limited to 'tests/benchmarks/benchmarks.cpp')
-rw-r--r--tests/benchmarks/benchmarks.cpp29
1 files changed, 29 insertions, 0 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"