Quote:
Originally Posted by cyber_punk
I noticed a hell of a speed increase to the responses from the randoms
|
Sorry but have you actually profiled it?
Because I've tested and was very surprised... Results, from my laptop, for 500000 calls:
Code:
random
-> Average time per call : 68 ns
-> Total execution time : 34 ms
-> Calls per second : 14705883 calls
MRandom
-> Average time per call : 51258 ns
-> Total execution time : 25629 ms
-> Calls per second : 19509 calls
(took the best 2 results)
My profiling method:
pawn Code:
#define BENCH_INIT(%1); new BT1=GetTickCount(),BT2,BI1,BI2=%1;
#define BENCH(%1(%2)); \
{\
for(BI1=0;BI1<BI2;BI1++)\
%1(%2);\
\
BT2=GetTickCount();\
BT1=BT2-BT1;\
\
printf("\n"#%1"\n -> Average time per call : %8.f ns\n -> Total execution time : %8d ms\n -> Calls per second : %8.f calls",\
(float(BT1)/BI2)*1000000,BT1,(float(BI2)/BT1)*1000);\
\
BT1=BT2;\
}
main()
{
BENCH_INIT(500000);
BENCH(random(101));
BENCH(random(101));
BENCH(MRandom(100));
BENCH(MRandom(100));
BENCH(random(101));
BENCH(random(101));
BENCH(MRandom(100));
BENCH(MRandom(100));
}
Just being curious about how you noticed a speed increase because as you can see, random() is about 750x faster