Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Really slow eval() on large data object
Forum Updated to NodeBB v4.3 + New Features

Really slow eval() on large data object

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 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.
  • C Offline
    C Offline
    chocis
    wrote on last edited by
    #1

    Hi, I've got a project where I need to download data from service, which returns data in javascript object string, which normally would be evaluated using eval(). I've got no way to change that service - i.e. to return JSON.

    The returned object is ~300kb and need to be evaluated to process it. I've tried using eval() from QML and QJSEngine::evaluate from C++ and it is realllllly slow (~30 seconds). As I understand QMLs eval() uses QJSEngine under the hood, so there is no difference.

    For now the only reasonable solution is to use QScriptEngine::evaluate, which does the parsing almost instantly, but
    as I understand that is the old engine and I don't want an extra dependency/object if QJSEngine is included by default (at least I think so).

    Could this be a QJSEngine bug, or no one really has optimized it for such large objects?
    Another solution would maybe be parsing the response manually, because it contains only array with objects and arrays - so no javascript expressions.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on last edited by
      #2

      Hmmm u can use a man in the middle :) Create a little service with PHP or nodeJS that grab the response from your main service and let your helper service do the heavy work.

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chocis
        wrote on last edited by
        #3

        Thanks for suggestion, but I'm not big fan of hacky approaches and the app will connect directly to end device. It can happen anywhere - even where no public network is available, so that's not a solution.

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          Hi,

          [quote author="chocis" date="1425211151"]For now the only reasonable solution is to use QScriptEngine::evaluate, which does the parsing almost instantly, but
          as I understand that is the old engine and I don't want an extra dependency/object if QJSEngine is included by default (at least I think so).[/quote]It is safe to use QScriptEngine, as it is guaranteed to be supported for the lifetime of Qt 5.x.

          Also, QJSEngine is only included if you use QML.

          [quote author="chocis" date="1425211151"]Could this be a QJSEngine bug, or no one really has optimized it for such large objects?[/quote]I don't know exactly, but I do know that starting with Qt 5.2 QJSEngine uses a custom engine called V4. This engine is optimized for transferring data between C++ and QML, and as a side effect, performance for "pure JavaScript" was reduced compared to the previous engine (V8, which was designed for web browsers)

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          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