19.01.2011, 22:40
Whoa don't know how this one slipped under my radar for so long....just happened to be going through my IRC logs the other day and found a conversation from Blacklight talking about this.
For those not using this plugin here is a better example of the speed difference over pawns floatsqroot.
Using this benchmark script (Yom posted this on my random plugin...)
Here are the results....
For those not using this plugin here is a better example of the speed difference over pawns floatsqroot.
Using this benchmark script (Yom posted this on my random plugin...)
pawn Код:
#include <a_samp>
#include <pointtopoint>
#define BENCH_INIT(%1); new BT1=GetTickCount(),BT2,BI1,BI2=%1;
#define BENCH(%1(%2)); \
{\
for(BI1=0;BI1<BI2;BI1++)\
%1(%2);\
\
BT2=GetTickCount();\
BT1=BT2-BT1;\
\
printf("\n"#%1"\n -> Average time per call : %8.f ns\n -> Total execution time : %8d ms\n -> Calls per second : %8.f calls",\
(float(BT1)/BI2)*1000000,BT1,(float(BI2)/BT1)*1000);\
\
BT1=BT2;\
}
main()
{
BENCH_INIT(500000);
BENCH(floatsqroot((2579.6860 - 708.1278) * (2579.6860 - 708.1278) + (-1220.7325 - -1634.9844) * (-1220.7325 - -1634.9844) + (54.7770 - 4.1586) * (54.7770 - 4.1586)));
BENCH(floatsqroot((2579.6860 - 708.1278) * (2579.6860 - 708.1278) + (-1220.7325 - -1634.9844) * (-1220.7325 - -1634.9844) + (54.7770 - 4.1586) * (54.7770 - 4.1586)));
BENCH(PointToPoint3D(2579.6860, -1220.7325, 54.7770, 708.1278, -1634.9844, 4.1586));
BENCH(PointToPoint3D(2579.6860, -1220.7325, 54.7770, 708.1278, -1634.9844, 4.1586));
BENCH(floatsqroot((2579.6860 - 708.1278) * (2579.6860 - 708.1278) + (-1220.7325 - -1634.9844) * (-1220.7325 - -1634.9844) + (54.7770 - 4.1586) * (54.7770 - 4.1586)));
BENCH(floatsqroot((2579.6860 - 708.1278) * (2579.6860 - 708.1278) + (-1220.7325 - -1634.9844) * (-1220.7325 - -1634.9844) + (54.7770 - 4.1586) * (54.7770 - 4.1586)));
BENCH(PointToPoint3D(2579.6860, -1220.7325, 54.7770, 708.1278, -1634.9844, 4.1586));
BENCH(PointToPoint3D(2579.6860, -1220.7325, 54.7770, 708.1278, -1634.9844, 4.1586));
printf("Result of floatsqroot: %.4f", floatsqroot((2579.6860 - 708.1278) * (2579.6860 - 708.1278) + (-1220.7325 - -1634.9844) * (-1220.7325 - -1634.9844) + (54.7770 - 4.1586) * (54.7770 - 4.1586)));
printf("Result of PointToPoint3D: %.4f", PointToPoint3D(2579.6860, -1220.7325, 54.7770, 708.1278, -1634.9844, 4.1586));
Here are the results....
Код:
[18:39:13] floatsqroot -> Average time per call : 668 ns -> Total execution time : 334 ms -> Calls per second : 1497006 calls [18:39:13] floatsqroot -> Average time per call : 654 ns -> Total execution time : 327 ms -> Calls per second : 1529052 calls [18:39:14] PointToPoint3D -> Average time per call : 144 ns -> Total execution time : 72 ms -> Calls per second : 6944444 calls [18:39:14] PointToPoint3D -> Average time per call : 144 ns -> Total execution time : 72 ms -> Calls per second : 6944444 calls [18:39:14] floatsqroot -> Average time per call : 668 ns -> Total execution time : 334 ms -> Calls per second : 1497006 calls [18:39:14] floatsqroot -> Average time per call : 666 ns -> Total execution time : 333 ms -> Calls per second : 1501501 calls [18:39:14] PointToPoint3D -> Average time per call : 144 ns -> Total execution time : 72 ms -> Calls per second : 6944444 calls [18:39:14] PointToPoint3D -> Average time per call : 146 ns -> Total execution time : 73 ms -> Calls per second : 6849315 calls [18:39:14] Result of floatsqroot: 1917.5236 [18:39:14] Result of PointToPoint3D: 1917.5236