diff options
Diffstat (limited to 'tests/benchmarks/benchmarks.cpp')
-rw-r--r-- | tests/benchmarks/benchmarks.cpp | 29 |
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" |