summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/benchmarks.cpp29
-rw-r--r--tests/benchmarks/benchmarks.pro3
-rw-r--r--tests/tests.pro2
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