Posts Tagged ‘performance’

Script speedup: Running functions asynchronously

Wednesday, February 6th, 2008

This is something I’ve seen a long time ago, but never actually had the script for.  If you’ve got a slow process in your loop, for example:

for (var i=0;i<jedarray .length;i++) {
     reallySlowFunction("bob", "ted", fredObj, jedArray[i]);
}

You can just throw the function off to my function be executed in its own little time, and your loop can carry on.

for (var i=0;i<jedArray.length;i++) {
     setAsync(reallySlowFunction, ["bob", "ted", fredObj, jedArray[i]] );
}

Much faster! (more…)