Quote:
Originally Posted by danielkza
Actually conversions will happen anyway. All pawn literals are cells, therefore they need to be truncated to fit in a pack string, and must be re-converted to cells when being used in any statement, AFAIK.
EDIT: Apparently I'm /partially/ wrong, there are special opcodes for packed chars, but still, if you try to use any cell values into expressions conversions have to happen. I'll look into the Pawn manaul to see if there are better explations on the subject.
|
Even if you are wrong that was a smart point. I will ask for help to amxx profiler.
Edit:
The results (It's basically the same):
PHP Code:
#include <amxmodx>
#include <fakemeta>
new normal[33]
new packed[33 char]
setNormal(x,y)
{
normal[x] = y;
}
setPacked(x,y)
{
packed{x} = y;
}
getNormal(x)
{
return normal[x];
}
getPacked(x)
{
return packed{x};
}
public plugin_cfg()
{
for(new i=0;i<10000;i++)
{
new a = random_num(0,32)
new b = random_num(0,255)
setPacked(a,b)
setNormal(a,b)
getPacked(a);
getNormal(a);
setPacked(a,0)
setNormal(a,0)
getPacked(a);
getNormal(a);
}
server_cmd("quit")
}
Code:
date: Tue Apr 21 07:39:32 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | random_num | 20000 | 0.049776 / 0.000001 / 0.000101
n | server_cmd | 1 | 0.000014 / 0.000014 / 0.000014
p | plugin_cfg | 1 | 0.207914 / 0.207914 / 0.207914
f | setNormal | 20000 | 0.048192 / 0.000001 / 0.000045
f | setPacked | 20000 | 0.048167 / 0.000001 / 0.000092
f | getNormal | 20000 | 0.048578 / 0.000001 / 0.000067
f | getPacked | 20000 | 0.048613 / 0.000001 / 0.000098
0 natives, 0 public callbacks, 1 function calls were not executed.
date: Tue Apr 21 07:40:37 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | random_num | 20000 | 0.049495 / 0.000001 / 0.000079
n | server_cmd | 1 | 0.000013 / 0.000013 / 0.000013
p | plugin_cfg | 1 | 0.207875 / 0.207875 / 0.207875
f | setNormal | 20000 | 0.048272 / 0.000001 / 0.000079
f | setPacked | 20000 | 0.048243 / 0.000001 / 0.000193
f | getNormal | 20000 | 0.048381 / 0.000001 / 0.000220
f | getPacked | 20000 | 0.048462 / 0.000001 / 0.000080
0 natives, 0 public callbacks, 1 function calls were not executed.
PHP Code:
#include <amxmodx>
#include <fakemeta>
new normal[33]
new packed[33 char]
setNormal(x)
{
normal[x] = 33 | normal[x];
}
setPacked(x)
{
packed{x} = 33 | packed{x};
}
getNormal(x)
{
return 1 | normal[x];
}
getPacked(x)
{
return 1 | packed{x};
}
public plugin_cfg()
{
for(new i=0;i<10000;i++)
{
new a = random_num(0,32)
setPacked(a)
setNormal(a)
getPacked(a);
getNormal(a);
}
server_cmd("quit")
}
Code:
date: Tue Apr 21 07:57:38 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | random_num | 10000 | 0.026228 / 0.000001 / 0.001046
n | server_cmd | 1 | 0.000011 / 0.000011 / 0.000011
p | plugin_cfg | 1 | 0.104097 / 0.104097 / 0.104097
f | setNormal | 10000 | 0.028161 / 0.000001 / 0.001741
f | setPacked | 10000 | 0.024113 / 0.000001 / 0.000031
f | getNormal | 10000 | 0.024541 / 0.000001 / 0.000118
f | getPacked | 10000 | 0.024453 / 0.000001 / 0.000091
0 natives, 0 public callbacks, 1 function calls were not executed.
date: Tue Apr 21 08:05:27 2009 map: de_dust2
type | name | calls | time / min / max
-------------------------------------------------------------------
n | random_num | 10000 | 0.024472 / 0.000001 / 0.000101
n | server_cmd | 1 | 0.000010 / 0.000010 / 0.000010
p | plugin_cfg | 1 | 0.105678 / 0.105678 / 0.105678
f | setNormal | 10000 | 0.024440 / 0.000001 / 0.000139
f | setPacked | 10000 | 0.023782 / 0.000001 / 0.000051
f | getNormal | 10000 | 0.024079 / 0.000001 / 0.000009
f | getPacked | 10000 | 0.024073 / 0.000001 / 0.000031
0 natives, 0 public callbacks, 1 function calls were not executed.
__________________