Changeset 953 for XmlTools2/trunk


Ignore:
Timestamp:
Feb 10, 2014, 3:28:14 PM (11 years ago)
Author:
s10k
Message:

XmlTools
What if we increase the performance of javascript by 2.5 times or more? (trying multithreading)

Location:
XmlTools2/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XmlTools2/trunk/XmlTools.pro

    r944 r953  
    66#QT += qml #for use new google v8 qtscript engine
    77QT += script #for use old qtscript engine
    8 #QMAKE_CXXFLAGS+= -fopenmp
    9 #QMAKE_LFLAGS +=  -fopenmp #OpenMP (multithreading) support
     8QMAKE_CXXFLAGS+= -fopenmp
     9QMAKE_LFLAGS +=  -fopenmp #OpenMP (multithreading) support
     10
    1011
    1112macx {
  • XmlTools2/trunk/optionsparser.h

    r944 r953  
    11#ifndef OPTIONSPARSER_H
    22#define OPTIONSPARSER_H
    3 
    4 //#include <omp.h> // OpenMP support
    53
    64#include "xmlpatch.h"
  • XmlTools2/trunk/xmlpatch.cpp

    r947 r953  
    199199
    200200    std::cout << "@COMMAND patch operation output:\n"
    201     << "########################################################################"
    202     << std::endl;
     201              << "########################################################################"
     202              << std::endl;
    203203
    204204    OptionsParser myParser(Util::QStringToArgsArray(commandString));
     
    206206
    207207    std::cout
    208     << "########################################################################"
    209     << std::endl;
     208            << "########################################################################"
     209            << std::endl;
    210210
    211211    UtilXmlTools::displaySuccessMessage(1,"@COMMAND");
     
    221221void XmlPatch::executeCustomCommandOperation(const QString &jsString, const QString &filesWildcard){
    222222
    223     QStringList filesToProcess;
    224 #ifdef _USE_OLD_JS_ENGINE
    225     QScriptEngine engine;
    226     QScriptValue engineResult; // variable to check for js_errors
    227 #else
    228     QJSEngine engine;
    229     QJSValue engineResult; // variable to check for js_errors
    230 #endif
    231 
    232     QString rexmlString, jsxmlString, currXmlFileString;
    233 
     223    QString rexmlString, jsxmlString;
     224    QStringList filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard);
     225
     226    if(filesToProcess.isEmpty()){
     227        UtilXmlTools::displayErrorMessage("@CUSTOM_CODE","No XML files were found for the wildcard: "+filesWildcard);
     228    }
    234229
    235230    QFile rexmlfile(":/resources/libs/rexml.js");
    236231    QFile jsxmlfile(":/resources/libs/jsxml.js");
    237232
    238     // Add echo function so user can debug the code
    239     QScriptValue echoFunction = engine.newFunction(echo);
    240     engine.globalObject().setProperty("echo", echoFunction);
    241 
    242     filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard);
    243 
    244     if(filesToProcess.isEmpty()){
    245         UtilXmlTools::displayErrorMessage("@CUSTOM_CODE","No XML files were found for the wildcard: "+filesWildcard);
    246     }
    247 
    248233    rexmlfile.open(QFile::ReadOnly | QFile::Text);
    249234    jsxmlfile.open(QFile::ReadOnly | QFile::Text);
     
    252237    jsxmlString=QTextStream(&jsxmlfile).readAll();
    253238
    254     engine.evaluate(rexmlString); // load js libraries
    255     engine.evaluate(jsxmlString);
    256 
    257239    // Process all XmlFiles
     240#pragma omp parallel for
    258241    for(int i=0; i<filesToProcess.size(); i++){
     242
     243        QString currXmlFileString;
     244
     245#ifdef _USE_OLD_JS_ENGINE
     246        QScriptEngine engine;
     247        QScriptValue engineResult; // variable to check for js_errors
     248#else
     249        QJSEngine engine;
     250        QJSValue engineResult; // variable to check for js_errors
     251#endif
     252
     253        // Add echo function so user can debug the code
     254        QScriptValue echoFunction = engine.newFunction(echo);
     255        engine.globalObject().setProperty("echo", echoFunction);
     256
     257        engine.evaluate(rexmlString); // load js libraries
     258        engine.evaluate(jsxmlString);
    259259
    260260        if(this->backupsEnabled){
  • XmlTools2/trunk/xmlpatch.h

    r926 r953  
    44#include "xmltools.h"
    55#include "optionsparser.h"
     6#include <omp.h> // OpenMP support
    67
    78class XmlPatch
Note: See TracChangeset for help on using the changeset viewer.