Difference between revisions of "Efficiency Tester"
Jump to navigation
Jump to search
m |
|||
Line 7: | Line 7: | ||
I've used i += 1 because I found it to be faster on the [[LSL Script Efficiency]] page. | I've used i += 1 because I found it to be faster on the [[LSL Script Efficiency]] page. | ||
Lots of people disagree with me that a += 1 is faster than + | Lots of people disagree with me that a += 1 is faster than ++a... If you don't like it, change it and then sue me :P. | ||
<pre> | <pre> |
Revision as of 10:47, 16 August 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Written by Xaviar Czervik, Modified by Strife Onizuka.
This code will test the efficiency of what ever is in the while loop.
I've used i += 1 because I found it to be faster on the LSL Script Efficiency page.
Lots of people disagree with me that a += 1 is faster than ++a... If you don't like it, change it and then sue me :P.
//IMPORTANT: Only perform tests in an empty region to reduce contamination and be sure to wearing no attachments. 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; //llInsertString(llDeleteSubString(stamp, 19, 19) + "000000", 23, ".") } default { state_entry() { //test variables float counter; //framework variables float i = 0; float j = 0; float max = 10000; float start = time(); do { //test counter += 1; }while (++i < max); float delta = time(); do ; while (++j < max); float end = time();//remove the time required by the framework float t = ((delta - start) - (end - delta))/max; llOwnerSay("The function in the loop took a total of " + (string)t + " milliseconds."); } }