Quote:
Originally Posted by Empowers
Wow thx for Great TUT!
Profiled:
Code:
Code:
date: Sun Apr 19 15:20:28 2009 map: de_dust
type | name | calls | time / min / max
-------------------------------------------------------------------
n | register_clcmd | 2 | 0.000019 / 0.000004 / 0.000015
p | array_test | 10 | 0.064196 / 0.006202 / 0.006642
p | bitsum_test | 10 | 0.029594 / 0.002811 / 0.003570
p | plugin_init | 1 | 0.000002 / 0.000002 / 0.000002
0 natives, 0 public callbacks, 3 function calls were not executed.
Tested on this code:
PHP Code:
#include <amxmodx>new array[33]new bitsumpublic plugin_init() { array[32] = false bitsum &= ~(1<<32) register_clcmd("array","array_test") register_clcmd("bitsum","bitsum_test")}public bitsum_test(){ for(new i;i<=1_000_000;i++) if(bitsum & (1<<32)) continue;}public array_test(){ for(new i;i<=1_000_000;i++) if(array[32]) continue;}
Now I'm thinking should I swap arrays with bitsums in my plugins code. It would use less memory, but it will be harder to understand the code.
|
That profile is wrong.
PHP Code:
#include <amxmodx>
new array[3]
new bitsum
public Index(n)
{
return array[n]
}
public Bit(n)
{
return (bitsum & (1<<n))
}
public plugin_cfg()
{
array[1] = true
bitsum = (1 << 1)
for(new i;i<10000;i++)
{
Bit(1)
Index(1);
Bit(2);
Index(2);
}
server_cmd("quit");
}
HTML Code:
date: Sun Apr 19 08:56:46 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | server_cmd | 1 | 0.000013 / 0.000013 / 0.000013
p | plugin_cfg | 1 | 0.088612 / 0.088612 / 0.088612
f | Bit | 20000 | 0.043302 / 0.000001 / 0.000040
f | Index | 20000 | 0.043490 / 0.000001 / 0.000104
0 natives, 2 public callbacks, 1 function calls were not executed.
date: Sun Apr 19 08:57:13 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | server_cmd | 1 | 0.000012 / 0.000012 / 0.000012
p | plugin_cfg | 1 | 0.094011 / 0.094011 / 0.094011
f | Bit | 20000 | 0.045281 / 0.000001 / 0.000012
f | Index | 20000 | 0.046318 / 0.000001 / 0.000488
0 natives, 2 public callbacks, 1 function calls were not executed.
date: Sun Apr 19 08:57:20 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | server_cmd | 1 | 0.000016 / 0.000016 / 0.000016
p | plugin_cfg | 1 | 0.092532 / 0.092532 / 0.092532
f | Bit | 20000 | 0.044500 / 0.000001 / 0.000023
f | Index | 20000 | 0.044818 / 0.000001 / 0.000137
0 natives, 2 public callbacks, 1 function calls were not executed.
date: Sun Apr 19 08:57:28 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | server_cmd | 1 | 0.000014 / 0.000014 / 0.000014
p | plugin_cfg | 1 | 0.095900 / 0.095900 / 0.095900
f | Bit | 20000 | 0.045795 / 0.000001 / 0.000194
f | Index | 20000 | 0.045659 / 0.000001 / 0.000117
0 natives, 2 public callbacks, 1 function calls were not executed.
Bitsums can't be used to replace is_user_alive like you have it, because 1<<32 is out of the bits that a cell can hold.
__________________