3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: (Script-related) How to make script optimisations? elaps time counter  (Read 864 times)

« on: June 26, 2012, 02:28:44 PM »

I was trying to understand if one script was faster than anther
Making comparative in time.

I try to make a code to calculate the time that my take to execute the script. with no result
I try later calculating a media time in 1 second to calculate.
but I'm too new with scripts. I'm bit lost here  :-\
i try to copy and past the code to be test a lot of times but did not work.
there is way to do this?
It was a difficult task for me
 I'm asking for help

i was thinking something like this

Code: [Select]
void Main() {

       ms1 = iSystemTime(7);

      // script to check go here ) loop?

      ms2 = iSystemTime(7);
      ms3 = ms2-ms1;

     // ValuePrint = ms3

}


Using: 3d rad v7.22 | IntelPentM 2Ghz, 1GB ram, 160 hdd | ATI Mobility Radeon 9600 128Mb 446Mhz (1920x1200 60 Hertz) | Ati Catalyst 09.3 Control Center 2009.0225.1546.28221 | AGP4x Performace profile| Dx9c D3D6.14.10.0647 OpenGL6.14.10.8543 |
« Reply #1 on: June 26, 2012, 09:50:34 PM »

The code i make is this one.
But if I add code there is no difference.



Code: [Select]
float count=0, ms1=0, ms2=0, ms3=0,ms4 , ms4b, ms5, R=0, c=3;
float x, s1, s2, s3, s4, delay;
float min, m1, m2, m3, m4, m5, m7;
float sec=0 ,c2,cycles, msMedia;
void Main()
{
      s1 = s2;   
      ms1 = ms2;
      m1  = m2;
///______________________________________________________________ start code


// script to check go here
// i copy and past 1000 times the code





///______________________________________________________________ end code
      ms2 = iSystemTime(7);
      if (ms2<ms1) {ms1=ms1-1000;} 
      ms3 = ms2-ms1; // is 31milisegundos each 1/60
      if ( ms3 < 0) { ms3=ms3*-1; }

      ms4 =  ms4 + ms3 ;
      ciclos++ ;
      msMedia = (ms4) / ciclos ;

      s1 = iSystemTime(6);
      sec++;
      if (sec == 1) { s2 = iSystemTime(6); }
      if (s2<s1) {s1=s1-60;}
      s3 = (s1 - s2 ) +60; /// s3 son segundos que pasan desde el incio
     
      ms5 = ms4/s3 ;

      m1 = iSystemTime(5);
      min++;
      if (m1 != m2) { min++; }
      m5 = min/s3;

      delay;
      c2++;
      if (c2 > 390) { m7 =((m7*(c2-391))+ m5) / (c2-390) ; }

      OUT_0 = cycles    ;//m7;         // ValuePrint = media
      OUT_22= ms3       ;//ms4;        // ValuePrint = min/s3 m5
      OUT_44= msMedia   ;//ms4;        // ValuePrint = min/s3 m5
      OUT_66= s3;
      OUT_88= ms5;   //Media
      OUT_110= ms4; //Counter
      OUT_132= m7;  //Media that start with delay
}
Using: 3d rad v7.22 | IntelPentM 2Ghz, 1GB ram, 160 hdd | ATI Mobility Radeon 9600 128Mb 446Mhz (1920x1200 60 Hertz) | Ati Catalyst 09.3 Control Center 2009.0225.1546.28221 | AGP4x Performace profile| Dx9c D3D6.14.10.0647 OpenGL6.14.10.8543 |
« Reply #2 on: June 27, 2012, 08:29:01 AM »
I don't get it. Every script loop takes 1/60 seconds, 0.666666667 seconds.

I did a test for this once, and it really is 1/60 second.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #3 on: July 12, 2012, 08:40:03 AM »
Every script loop takes 1/60 seconds, 0.666666667 seconds.



i Think making " a = 1 + 1 " is faster than " a = 8 / 4 "

because division is more complex equation and eat more time.

http://www.tantalon.com/pete/cppopt/appendix.php#AppendixC

so if i has to make 10.000 equations  every script loop i wish to choose the best solution.

fast examples:
problem number:
1)
         possible solution:

   A):   x = ( - b ) + a

   B):   x = a - b

i think B) is much faster


problem:
 2)
        possible solution
   A):    x = b - c

   B):   x = b - ( a * -1 )

   C):   x = c * -1     

    D):   x = -c           

   E)   x = a + b


3) possible solution
   A):    x =  ((a-b)*(a-b))+((c-d)*(c-d))

   B):   x =  1 - ( a * a )  // making b =1

   C):   a =  a * a
      x = -a + 1

« Last Edit: July 19, 2012, 09:53:44 PM by a_mattano »
Using: 3d rad v7.22 | IntelPentM 2Ghz, 1GB ram, 160 hdd | ATI Mobility Radeon 9600 128Mb 446Mhz (1920x1200 60 Hertz) | Ati Catalyst 09.3 Control Center 2009.0225.1546.28221 | AGP4x Performace profile| Dx9c D3D6.14.10.0647 OpenGL6.14.10.8543 |
« Reply #4 on: July 19, 2012, 09:57:04 PM »

I tried to measure the time it takes to find the result
Using: 3d rad v7.22 | IntelPentM 2Ghz, 1GB ram, 160 hdd | ATI Mobility Radeon 9600 128Mb 446Mhz (1920x1200 60 Hertz) | Ati Catalyst 09.3 Control Center 2009.0225.1546.28221 | AGP4x Performace profile| Dx9c D3D6.14.10.0647 OpenGL6.14.10.8543 |
Pages: [1]