17.06.2010, 09:38
Quote:
Originally Posted by Trooper[Y
]
Tested ? |
Originally Posted by Trooper[Y
]
Tested ? |
#define GetDistance(%1,%2,%3,%4,%5,%6) floatadd(floatadd(floatsqroot(floatpower(floatsub(%1, %4), 2)), floatsqroot(floatpower(floatsub(%2, %5), 2))), floatsqroot(floatpower(floatsub(%3, %6), 2)))
#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));
[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
I can't download the source code.
I'd like to take a look at it... Could someone please reupload it? |
stock DistanceToPoint(playerid, Float:PointX, Float:PointY, Float:PointZ) { new Float:PosX, Float:PosY, Float:PosZ; GetPlayerPos(playerid, PosX, PosY, PosZ); return floatsqroot((PosX-PointX)*(PosX-PointX)+(PosY-PointY)*(PosY-PointY)+(PosZ-PointZ)*(PosZ-PointZ))) }