Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
|
04-23-2015
, 12:15
Re: ~containi and != -1
|
#14
|
Code:
#include <amxmodx>
#define runs 10
#define loops 100000000 // That is 100 million
#define TimerStart() tickcount()
#define TimerMid(%0) ( tickcount() - %0 )
#define TimerStop(%0) ( %0 = tickcount() - %0 )
#define TimerDays(%0) ( %0 / 86400000 )
#define TimerHours(%0) ( %0 % 86400000 / 3600000 )
#define TimerMinutes(%0) ( %0 % 3600000 / 60000 )
#define TimerSeconds(%0) ( %0 % 60000 / 1000 )
#define TimerMilliseconds(%0) ( %0 % 1000 )
public plugin_init() {
register_plugin("Test Plugin 3", "", "[ --{-@ ]");
new test = -1;
new hTimer = TimerStart();
new Time;
for ( new i = 0 ; i < runs ; i++ ) {
hTimer = TimerStart();
for ( new j = 0 ; j < loops ; j++ ) {
if ( test != -1 ) { }
}
TimerStop(hTimer);
server_print("1st method, run %d: %ds, %dms.", i + 1, TimerSeconds(hTimer), TimerMilliseconds(hTimer));
Time += hTimer;
}
server_print("1st method, total time: %dm, %ds, %dms", TimerMinutes(Time), TimerSeconds(Time), TimerMilliseconds(Time));
Time /= runs
server_print("1nd method, average time: %ds, %dms.^n", TimerSeconds(Time), TimerMilliseconds(Time));
Time = 0;
for ( new i = 0 ; i < runs ; i++ ) {
hTimer = TimerStart();
for ( new j = 0 ; j < loops ; j++ ) {
if ( ~test ) { }
}
TimerStop(hTimer);
server_print("2nd method, run %d: %ds, %dms.", i + 1, TimerSeconds(hTimer), TimerMilliseconds(hTimer));
Time += hTimer;
}
server_print("2nd method, total time: %dm, %ds, %dms", TimerMinutes(Time), TimerSeconds(Time), TimerMilliseconds(Time));
Time /= runs
server_print("2nd method, average time: %ds, %dms.^n", TimerSeconds(Time), TimerMilliseconds(Time));
Time = 0;
for ( new i = 0 ; i < runs ; i++ ) {
hTimer = TimerStart();
for ( new j = 0 ; j < loops ; j++ ) {
}
TimerStop(hTimer);
server_print("nothing at all, run %d: %ds, %dms.", i + 1, TimerSeconds(hTimer), TimerMilliseconds(hTimer));
Time += hTimer;
}
server_print("nothing at all, total time: %dm, %ds, %dms", TimerMinutes(Time), TimerSeconds(Time), TimerMilliseconds(Time));
Time /= runs
server_print("nothing at all, average time: %ds, %dms.", TimerSeconds(Time), TimerMilliseconds(Time));
}
Code:
1st method, run 1: 4s, 563ms.
1st method, run 2: 4s, 564ms.
1st method, run 3: 4s, 561ms.
1st method, run 4: 4s, 564ms.
1st method, run 5: 4s, 563ms.
1st method, run 6: 4s, 565ms.
1st method, run 7: 4s, 559ms.
1st method, run 8: 4s, 565ms.
1st method, run 9: 4s, 561ms.
1st method, run 10: 4s, 551ms.
1st method, total time: 0m, 45s, 616ms
1nd method, average time: 4s, 561ms.
2nd method, run 1: 4s, 563ms.
2nd method, run 2: 4s, 558ms.
2nd method, run 3: 4s, 564ms.
2nd method, run 4: 4s, 561ms.
2nd method, run 5: 4s, 566ms.
2nd method, run 6: 4s, 562ms.
2nd method, run 7: 4s, 564ms.
2nd method, run 8: 4s, 561ms.
2nd method, run 9: 4s, 565ms.
2nd method, run 10: 4s, 565ms.
2nd method, total time: 0m, 45s, 629ms
2nd method, average time: 4s, 562ms.
nothing at all, run 1: 1s, 386ms.
nothing at all, run 2: 1s, 386ms.
nothing at all, run 3: 1s, 387ms.
nothing at all, run 4: 1s, 386ms.
nothing at all, run 5: 1s, 384ms.
nothing at all, run 6: 1s, 386ms.
nothing at all, run 7: 1s, 386ms.
nothing at all, run 8: 1s, 386ms.
nothing at all, run 9: 1s, 385ms.
nothing at all, run 10: 1s, 386ms.
nothing at all, total time: 0m, 13s, 858ms
nothing at all, average time: 1s, 385ms.
__________________
Last edited by Black Rose; 04-23-2015 at 12:16.
|
|