Change font size
It is currently Tue Dec 18, 2018 12:39 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: New lag-o-meter script
PostPosted: Sat Jul 07, 2012 4:33 am 

Joined: Fri Apr 13, 2012 1:19 am
Posts: 26
I have been having problems with lag on my sim and wrote this little lag-o-meter script. I was unhappy with some other lag meter scripts I had seen. Most of those simply displayed the dilation and FPS without question. I was discovering that my timer() events were getting called later and later and I wanted to know how late they were. It also measures how late llSleep calls return.

I expect a certain amount of delay from sampling error of the sim script frame clock. But I was seeing a 1 second timer taking 4 seconds or longer. (Turns out the server was spending all that time resizing sculpted prims. Stop resizing sculpted prims and the timers are closer to being on time. Go figure.)

Stick this script in a prim. You can wear it as a HUD, or rez a copy.
{L_CODE}:
//Lag-o-meter
// by Kayaker Magic, aka Mike Kayaker or Kayaker Mike

float average=0.0;
float avesleep=0.0;
float number=0.0;
float timerstep=1.0;
float sleepstep=0.1;

string percent(float got,float expected)
{
    return(llGetSubString((string)(100.0*((got-expected)/expected)),0,3)+"%");
}
default
{
    state_entry()
    {
        llGetAndResetTime();
        llSetTimerEvent(timerstep);
    }

    timer()
    {
        float time=llGetAndResetTime();
        average += time+sleepstep;;
        number += 1;
        llSleep(sleepstep);
        float short=llGetAndResetTime();
        avesleep += short;
        llSetText( "The timers are late by:"+
            "\nLast timer: "    +percent(time+sleepstep,timerstep)+
            "\nAverage timer: "+ percent(average/number,timerstep)+
            "\n"+"Short Sleep: "+percent(short,sleepstep)+
            "\nAverage sleep: " +percent(avesleep/number,sleepstep)+
            "\nDilation: "      +llGetSubString((string)(1.0-llGetRegionTimeDilation()),0,3)+"%"+
            "\nFPS: "           +llGetSubString((string)llGetRegionFPS(),0,3)+
            "\nTouch bar to reset"
             ,<0,1,0>,1.0);
        if (number>10000.0)  //reset the statistics every so often
        {
            number=0.0;
            average=0.0;
            avesleep=0.0;
            llSetText("reset",<1,0,0>,1.0);
        }
    }
    touch_start(integer num)
    {
        number=0.0;  //reset the statistics on a touch
        average=0.0;
        avesleep=0.0;
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net