Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QJsEngine vs QScripEngine speed
Forum Updated to NodeBB v4.3 + New Features

QJsEngine vs QScripEngine speed

Scheduled Pinned Locked Moved General and Desktop
qjsengineqscriptengine
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ivareske
    wrote on last edited by
    #1

    As far as I understood the QScriptEngine class is being replaced by the QJSEngine class. I also read QJSEngine should be more efficient. I however experience the opposite, the execution of the script function I have becomes about 10 times slower with QJSEngine compared to QScriptEngine, and a factor of 100 slower compared to using QScriptEngine together with QScriptProgram (I tested calling the function below 1000 times in a loop, got about 3000, 300 and 30 msec). My function looks like this, it calculates the gas density based on a user-specified function of pressure and temperature:

    double computeScriptFunction(const double &p, const double &T, const QString &program)const{
    static ScriptEngine e;
    static ScriptValue globObj;
    static bool isInit=false;
    if(!isInit){
    globObj = e.globalObject();
    isInit = true;
    }
    globObj.setProperty("p",p);
    globObj.setProperty("T",T);
    ScriptValue val = e.evaluate(program);
    return val.toNumber();
    }

    ScriptEngine and ScriptValue are here typedefs for QJSEngine/QScriptEngine and QJSValue/QScriptValue depending on what I want to use. The code I use when using QScriptProgram is identical except that the function input is a QScriptProgram and not a QString.

    Does anyone have any experience with the speed of QJSEngine vs QScriptEngine?
    Does there exist anything similar to QScriptProgram for QJSEngine?

    Regards, Ivar

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved