All pastes #1299061 Raw Edit

PointToPoint timing analysis

public cpp v1 · immutable
#1299061 ·published 2009-01-03 17:23 UTC
rendered paste body
#include <a_samp>#define Type8(%0,%1,%2,%3,%4,%5,%6) \	(((%0 - %3) * (%0 - %3)) + ((%1 - %4) * (%1 - %4)) + ((%2 - %5) * (%2 - %5)) <= %6 * %6)main(){	new		time0,		time1,		time2,		time3,		time4,		time5,		time6,		time7,		time8,		Float:x = 10.0,		Float:y = 20.0,		Float:z = 30.0,		Float:dist = 70.0,		Float:pos[1][3] = {{40.0, 50.0, 60.0}};	#define LOOPS 1000000	time0 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type1(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time1 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type2(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time2 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type3(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time3 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type4(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time4 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type5(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time5 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type6(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time6 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type7(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time7 = GetTickCount();	for (new i = 0; i < LOOPS; i++)	{		if (Type8(x, y, z, pos[0][0], pos[0][1], pos[0][2], dist)) {}	}	time8 = GetTickCount();	printf("%d %d %d %d %d %d %d %d %d", time1 - time0, time2 - time1, time3 - time2, time4 - time3, time5 - time4, time6 - time5, time7 - time6, time8 - time7);	return 1;}Type1(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	x1 = (x1 > x2) ? x1 - x2 : x2 - x1;	if (x1 > dist) return false;	y1 = (y1 > y2) ? y1 - y2 : y2 - y1;	if (y1 > dist) return false;	z1 = (z1 > z2) ? z1 - z2 : z2 - z1;	if (z1 > dist) return false;	return true;}Type2(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	dist *= dist;	x1 -= x2;	x1 *= x1;	if (x1 > dist) return false;	y1 -= y2;	y1 *= y1;	if (y1 > dist) return false;	z1 -= z2;	z1 *= z1;	if (z1 > dist) return false;	return true;}Type3(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	x1 -= x2;	x1 *= x1;	y1 -= y2;	y1 *= y1;	z1 -= z2;	z1 *= z1;	return (x1 + y1 + z1 <= dist * dist);}Type4(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	x1 -= x2;	y1 -= y2;	z1 -= z2;	return ((x1 * x1) + (y1 * y1) + (z1 * z1) <= dist * dist);}Type5(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2)) <= dist * dist);}Type6(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	dist *= dist;	x1 -= x2;	if (x1 * x1 > dist) return false;	y1 -= y2;	if (y1 * y1 > dist) return false;	z1 -= z2;	if (z1 * z1 > dist) return false;	return true;}Type7(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist){	dist *= dist;	if ((x1 - x2) * (x1 - x2) > dist) return false;	if ((y1 - y2) * (y1 - y2) > dist) return false;	if ((z1 - z2) * (z1 - z2) > dist) return false;	return true;}