Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Weird performance boost when calling QJSValue aliased property
Qt 6.12 LTS is out! See what's new in the release blog

Weird performance boost when calling QJSValue aliased property

Scheduled Pinned Locked Moved Unsolved General and Desktop
qjsengineperformance
1 Posts 1 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    mjakubowski
    wrote on last edited by
    #1

    Hello,

    I noticed a strange behavior in Qt, checked on 5.5.1 and 5.7.0 beta. Have a look at the code here. It's a simple example, I have a MyObj class with an overloaded method v: one for reading from and the other one for writing into a QVariantMap. An instance of this class is passed to QJSEngine, which then evaluates body like below and calls this via QJSValue::call 5 million times.

    (function() { obj.v('test1', obj.v('test1') + 0.05); })
    

    The weird thing is that if I do the following:

    QJSValue myObjJS = engine.newQObject(&myObj);
    myObjJS.setProperty("z", myObjJS.property("v"));
    

    And take the following function using this new aliased property:

    (function() { obj.z('test2', obj.z('test2') + 0.05); })
    

    it is noticeably faster, with both Qt 5.5.1 and 5.7.0, debug and release builds:

    ~/projects/builds/qjsperftest-5.5.1%> ./qjsperftest
    Version =  5.5.1
    QVariant(double, 250000)  in  4892  ms
    QVariant(double, 250000)  in  2871  ms
    
    ~/projects/builds/qjsperftest-5.7.0%> ./qjsperftest
    Version =  5.7.0
    QVariant(double, 250000)  in  5907  ms
    QVariant(double, 250000)  in  3514  ms
    
    ~%> gcc --version
    gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413
    

    Any ideas what could be the reason here? I mean, I'm not going to complain having found a faster way to call these methods, but it seems rather weird.

    -- Marcin

    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
    • Unsolved