summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/qscriptengine/tst_qscriptengine.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
index 81dedfa..515285d 100644
--- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
@@ -69,6 +69,7 @@ private slots:
void pushAndPopContext();
void toStringHandle();
void castValueToQreal();
+ void nativeCall();
};
tst_QScriptEngine::tst_QScriptEngine()
@@ -225,5 +226,21 @@ void tst_QScriptEngine::castValueToQreal()
}
}
+static QScriptValue native_function(QScriptContext *, QScriptEngine *)
+{
+ return 42;
+}
+
+void tst_QScriptEngine::nativeCall()
+{
+ QScriptEngine eng;
+ eng.globalObject().setProperty("fun", eng.newFunction(native_function));
+ QBENCHMARK{
+ eng.evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n"
+ " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }");
+ }
+}
+
+
QTEST_MAIN(tst_QScriptEngine)
#include "tst_qscriptengine.moc"