summaryrefslogtreecommitdiffstats
path: root/examples/script/context2d
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-02-03 14:48:02 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2011-02-04 11:12:59 (GMT)
commit6163c36249eea0a2a578b9990470fcaa2f7bcf5f (patch)
tree490e647d331d12c017b86af5641d9d038485e486 /examples/script/context2d
parentda48bbe66b7821416bee1ebc0215bc93e68f0a2a (diff)
downloadQt-6163c36249eea0a2a578b9990470fcaa2f7bcf5f.zip
Qt-6163c36249eea0a2a578b9990470fcaa2f7bcf5f.tar.gz
Qt-6163c36249eea0a2a578b9990470fcaa2f7bcf5f.tar.bz2
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')
-rw-r--r--examples/script/context2d/environment.cpp17
-rw-r--r--examples/script/context2d/environment.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/examples/script/context2d/environment.cpp b/examples/script/context2d/environment.cpp
index 7d6d6f8..e68c1ca 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)
{
diff --git a/examples/script/context2d/environment.h b/examples/script/context2d/environment.h
index dd92e85..221875f 100644
--- a/examples/script/context2d/environment.h
+++ b/examples/script/context2d/environment.h
@@ -78,6 +78,8 @@ public:
//! [0]
QScriptEngine *engine() const;
+ bool hasIntervalTimers() const;
+ void triggerTimers();
//! [1]
public slots: