diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/benchmarks.cpp | 29 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 3 |
2 files changed, 32 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" 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) |