diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-02-03 15:48:02 +0100 |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2011-02-04 12:12:59 +0100 |
commit | 6163c36249eea0a2a578b9990470fcaa2f7bcf5f (patch) | |
tree | 490e647d331d12c017b86af5641d9d038485e486 /examples/script/context2d/environment.cpp | |
parent | da48bbe66b7821416bee1ebc0215bc93e68f0a2a (diff) |
Add Context2D QtScript benchmark
Reuse the Context2D implementation from
examples/script/context2d and create a benchmark out of it.
This benchmark actually measures a meaningful, real-world
use case.
Task-number: QTBUG-17192
Reviewed-by: Jedrzej Nowacki
Diffstat (limited to 'examples/script/context2d/environment.cpp')
-rw-r--r-- | examples/script/context2d/environment.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/script/context2d/environment.cpp b/examples/script/context2d/environment.cpp index 7d6d6f880d..e68c1caf36 100644 --- a/examples/script/context2d/environment.cpp +++ b/examples/script/context2d/environment.cpp @@ -363,6 +363,23 @@ QScriptValue Environment::evaluate(const QString &code, const QString &fileName) return m_engine->evaluate(code, fileName); } +bool Environment::hasIntervalTimers() const +{ + return !m_intervalHash.isEmpty(); +} + +// This is used by the Context2D QtScript benchmark. +void Environment::triggerTimers() +{ + for (int x = 0; x < 2; ++x) { + QList<int> timerIds = x ? m_intervalHash.keys() : m_timeoutHash.keys(); + for (int i = 0; i < timerIds.size(); ++i) { + QTimerEvent fakeEvent(timerIds.at(i)); + timerEvent(&fakeEvent); + } + } +} + //! [2] QScriptValue Environment::toWrapper(QObject *object) { |