Nominate our 2022 Qt Champions!

QJSEngine vs. (deprecated) QScriptEngine performance - old thing winning!

  • Re: QScriptEngine vs. QJSEngine?

    I was given a task to compare performance scripting solutions in Qt and to my surprise QScriptEngine was the absolute winner of the contest, especially with the ability of keeping pre-parsed script in QScriptProgram.
    The evaluation of 30.000 expressions was 3-6 times better on first evaluation round, 6-30 times on the repeated evaluation (depending on formulae complexity reaching from simple calculation "100 + (5/1.23)" to more complicated 2 line expressions with some variable bindings).

    I was truly astonished that QJSEngine performed that miserably at simple calculations as it is the engine powering QML. Maybe QJSEngine-QQmlEngine is optimized toward property notifications/changes, maybe this performance gap is the reason why QtScript was not yet been phased out.
    Maybe I am completely wrong in general. Anyone else experienced this?

    Code involved is here in

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    I'd recommend bringing this to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.

  • You were right, Ulf Hermann on the interest mailing list pointed me very swiftly to the way how QJSEngine can do precompiled things.

    QJSValue fun = myEngine.evaluate("(function(a, b) { return a + b;})");
    QJSValueList args; args << 1 << 2;
    QJSValue threeAgain =, args); regards,

    So you need to keep the precompiled functions and corresponding myEngine alive and the evaluation runs very quickly, beating the QScriptEngine

Log in to reply