It appears that get_pcvar_num and get_xvar_num are executed with the same speed.
fake natives are slower.
Plugins 1 :
PHP Code:
#include <amxmodx>
#define VERSION "0.0.1"
#define PLUGIN "xvar profile 1"
public xvar1 = 10
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
register_cvar("amx_cvar_test", "1337")
}
public plugin_natives()
{
register_native("get_variable_test", "get_variable_test")
}
public get_variable_test()
{
return xvar1
}
Plugin 2 (profiled) :
PHP Code:
#include <amxmodx>
#define VERSION "0.0.1"
#define PLUGIN "xvar profile 2"
native get_variable_test()
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
}
public plugin_cfg()
{
new pcvar = get_cvar_pointer("amx_cvar_test")
new xvar = get_xvar_id("xvar1")
for(new i; i<1000; i++)
{
get_pcvar_num(pcvar)
get_xvar_num(xvar)
get_variable_test()
}
}
Dump :
Code:
date: Fri Sep 24 19:18:23 2010 map: de_aztec
type | name | calls | time / min / max
-------------------------------------------------------------------
n | register_plugin | 1 | 0.000001 / 0.000001 / 0.000001
n | get_cvar_pointer | 1 | 0.000001 / 0.000001 / 0.000001
n | get_xvar_id | 1 | 0.000001 / 0.000001 / 0.000001
n | get_pcvar_num | 1000 | 0.000180 / 0.000000 / 0.000000
n | get_xvar_num | 1000 | 0.000179 / 0.000000 / 0.000000
n | get_variable_test | 1000 | 0.000245 / 0.000000 / 0.000001
p | plugin_cfg | 1 | 0.000561 / 0.000561 / 0.000561
p | plugin_init | 1 | 0.000001 / 0.000001 / 0.000001
0 natives, 0 public callbacks, 2 function calls were not executed.
__________________