Changeset 958


Ignore:
Timestamp:
Feb 15, 2014, 2:36:05 AM (11 years ago)
Author:
s10k
Message:

XmlTools
More updates.

Location:
XmlTools2/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XmlTools2/trunk/readme.txt

    r952 r958  
    11Readme.txt
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3 XmlTools v2.0
     3XmlTools v2.0a
    44~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    55
     
    6262Change Log:
    6363----------------------------------
     642.0a, 15-02-2014
     65-Added multithreading support for @CUSTOM_COMMAND, use wildcards in multiple files for the same js code to
     66take advantage of this (performance may increase over 2.5 times)
     67-Now a warning is given if a user javascript code (@CUSTOM_COMMAND) takes too much time to finish
     68-Fixed small bug when applying patches with @COMMAND + --no-verbose where some std output should not be displayed
     69----------------------------------
    64702.0, 08-02-2014
    6571-Rewrite XmlTools fom the scratch from C# to C++ in order to increase (much!) the performance of the program
  • XmlTools2/trunk/util.cpp

    r942 r958  
    88QString AppExecutable="./"+AppName; // Mac OS needs unix like executing
    99#endif
    10 QString AppVersion="2.0";
     10QString AppVersion="2.0a";
    1111}
    1212
  • XmlTools2/trunk/xmlpatch.cpp

    r956 r958  
    245245        QScriptEngine engine;
    246246        QScriptValue engineResult; // variable to check for js_errors
     247        double elapsed_secs; // elapsed seconds that a user script took
     248        clock_t begin; // seconds that a script started
    247249
    248250        // Add echo function so user can debug the code
     
    269271        engine.globalObject().setProperty("$xmlData",currXmlFileString);
    270272
     273        if(this->verboseEnabled){
     274            begin = clock();
     275        }
     276
    271277        // main needs to be called so the user code is evaluated
     278        // alternatively you can do: myFunc=engine.evaluate('(function main(){})'); myFunc.call();
     279        // Note the () around the function
    272280        engineResult=engine.evaluate("main(); function main() {"+jsString+"}"); // main funtion allows to use return to exit prematurely from user code
     281
     282        if(this->verboseEnabled){
     283            elapsed_secs = double(clock() - begin) / CLOCKS_PER_SEC;
     284
     285            // Warn the user if the script took much time
     286            if(elapsed_secs>SLOW_SCRIPT_TIME){
     287                std::cout << "Warning: Slow javascript code detected.\n" <<
     288                             "Warning: Script execution seconds: " << elapsed_secs
     289                          << std::endl;
     290            }
     291        }
    273292
    274293        if (engine.hasUncaughtException()) {
     
    433452            // Add --no-backups and --no-verbose if patch was called with that arguments
    434453            if(!this->backupsEnabled){
    435                 command.append(" --no-backups");
     454                command.append(" --no-backups ");
    436455            }
    437456
    438457            if(!this->verboseEnabled){
    439                 command.append(" --no-verbose");
     458                command.append(" --no-verbose ");
    440459            }
    441460
  • XmlTools2/trunk/xmlpatch.h

    r956 r958  
    55#include "optionsparser.h"
    66#include <omp.h> // OpenMP support
     7#include <ctime> // script execution time calculation
     8
     9#define SLOW_SCRIPT_TIME 0.1 // if a user script takes more than 0.1 seconds to execute give a warning.
    710
    811class XmlPatch
Note: See TracChangeset for help on using the changeset viewer.