Difference between revisions of "Efficiency Tester"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 5: Line 5:
If you don't like it, sue me :P.  
If you don't like it, sue me :P.  


<math>a^b+c</math>
<math> a^b+c </math>


integer time() {
integer time() {

Revision as of 06:56, 16 May 2007

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.

If you don't like it, sue me :P.

<math> a^b+c </math>

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.");
 }

}