Hello,
just found strange performance issue in the javascript engine.
Here is test file, and two scripts which changes style of all objects. Both scripts are exactly the same, but second uses execCommand function to run.
test1.js
code: var t = new Date(); var obj = moi.geometryDatabase.getObjects(); for ( var i = 0; i < obj.length; i++) obj.item(i).styleIndex = 1; moi.log("test1: "+(new Date() - t) / 1000 + " seconds\r");
test2.js
code: moi.command.execCommand ('var t = new Date(); var obj = moi.geometryDatabase.getObjects(); for ( var i = 0; i < obj.length; i++) obj.item(i).styleIndex = 2; moi.log("test2: "+(new Date() - t) / 1000 + " seconds\\r");');
Log:
code: test1: 6.651 seconds <--- ???? >:-[
test2: 0.002 seconds
Look at this. Why the plain script takes much more time to run?
|