I created a project use cocos2d-x & js-binding, wrote it in the main.js
function testIt() {
var max = 900;
var start = new Date().getTime();
for (var i = 0; i < max; ++i) {
for (var j = 0; j < max; ++j) {}
}
cc.log("cost:"+(new Date().getTime() - start));
}
testIt();
It prints:
cost:821
but if I test it in the chrome’s developer tool,it only takes 9ms.
Is the cost of binding? Or where I made a mistake?
yes, I met same problem. for the processing of an array with a lot of elements, it is very very slow.
I think chrome/nodejs V8 is realtime compiling and optimise a lot has a better performance than SpiderMonkey.
My solution is avoiding Intensive computing in javascript and using c++ do the Intensive computing then construct jsb to get the computing result