Efficiency Tester
Revision as of 07:58, 19 May 2007 by Xaviar Czervik (talk | contribs)
This code will test the efficiency of what ever is in the while loop.
I've used i += 1 because it was found to be faster on the LSL Script Efficiency page.
Lots of people disagree with me that a += 1 is faster than +=a, but check out the LSL Script Efficiency... If you don't like it, change it and sue me :P.
integer time() { string stamp = llGetTimestamp(); return (integer) llGetSubString(stamp, 11, 12) * 3600000 + (integer) llGetSubString(stamp, 14, 15) * 60000 + llRound((float)llGetSubString(stamp, 17, -2) * 1000000.0)/1000; } default { state_entry() { float i = 0; float max = 10000; float current = time(); while (i < max) { i += 1; } float t = (time()+-current)/max; llOwnerSay("The function in the loop took a total of " + (string)t + " milliseconds."); } }