Code
#include <amxmodx>
#define TIMES 100000000
public plugin_init()
{
register_plugin("speed test","0","DaTa")
register_concmd("go","res")
}
public res(id)
{
static a, i, iTics_cycle, iTics_VEN, iTics_se7h
iTics_cycle = tickcount()
for(i = 0; i < TIMES; i++) {}
iTics_cycle = tickcount() - iTics_cycle
iTics_se7h = tickcount()
for(i = 0; i < TIMES; i++)
a = floatround(a/10.0)*10
iTics_se7h = tickcount() - iTics_se7h - iTics_cycle
iTics_VEN = tickcount()
for(i = 0; i < TIMES; i++)
if (a - (a = a / 10 * 10) >= 5)
a += 10
iTics_VEN = tickcount() - iTics_VEN - iTics_cycle
console_print(id, "cycle %d; VEN %d; se7h %d;^nWinner is %s (x%.3f times faster)!", iTics_cycle, iTics_VEN, iTics_se7h, iTics_VEN < iTics_se7h ? "VEN" : "se7h", iTics_VEN < iTics_se7h ? float(iTics_se7h)/float(iTics_VEN) : float(iTics_VEN)/float(iTics_se7h))
return PLUGIN_HANDLED
}
Quote
go
cycle 219; VEN 3296; se7h 8672;
Winner is VEN (x2.631 times faster)!
go
cycle 219; VEN 3296; se7h 8734;
Winner is VEN (x2.649 times faster)!
go
cycle 219; VEN 3312; se7h 8703;
Winner is VEN (x2.627 times faster)!
go
cycle 219; VEN 3328; se7h 8703;
Winner is VEN (x2.615 times faster)!