//
vs.net 2003 p4 3.0G,512MB
#include " stdafx.h "
#include < xmmintrin.h >
#include " windows.h "
template < class Type >
struct Rectt
{
Type x;
Type y;
Type right;
Type bottom;;
} ;
typedef __declspec(align( 16 )) Rectt < float > Rect;
// 是否包含r矩形
extern " C " bool RectAndRect( const Rect * l0, const Rect * l1, const Rect * r)
{
int flag = 0;
int flag1 = 1;
__asm
{
mov eax,[l0];
movaps xmm0,[eax];
mov eax,[r];
movaps xmm1, [eax];
cmpps xmm0, xmm1, 1;
movmskps eax, xmm0;
mov flag, eax;
mov eax,[l1];
movaps xmm0,[eax];
cmpps xmm0, xmm1, 1;
movmskps eax, xmm0;
mov flag1, eax;
}
return flag == 15 && flag1 == 0;
}
int _tmain( int argc, _TCHAR * argv[])
{
int COUNT = 1000000;
Rect l = {0,0,100,100};
Rect* ls = new Rect[COUNT];
for ( int cnt =0; cnt <COUNT; cnt++ )
{
ls[cnt].x = rand()%10+1;
ls[cnt].y = rand()%10+1;
ls[cnt].right = 10;
ls[cnt].bottom = 10;
}
//l的左上点
Rect ll0 = {0.0f,0.0f,0.0f,0.0f};
//l的右下点
Rect ll1 = {100.0f,100.0f,100.0f,100.0f};
LARGE_INTEGER start,end,fre;
::QueryPerformanceCounter(&start);
::QueryPerformanceFrequency(&fre);
bool res;
for ( int cnt =0; cnt <COUNT; cnt++ )
{
res = RectAndRect(&ll0,&ll1,ls+cnt);
}
::QueryPerformanceCounter(&end);
double ress = double(end.QuadPart - start.QuadPart)/(double)fre.QuadPart;
std::cout<<ress<<std::endl;
std::cout<<res<<std::endl;
delete[] ls;
return 0;
}
#include " stdafx.h "
#include < xmmintrin.h >
#include " windows.h "
template < class Type >
struct Rectt
{
Type x;
Type y;
Type right;
Type bottom;;
} ;
typedef __declspec(align( 16 )) Rectt < float > Rect;
// 是否包含r矩形
extern " C " bool RectAndRect( const Rect * l0, const Rect * l1, const Rect * r)
{
int flag = 0;
int flag1 = 1;
__asm
{
mov eax,[l0];
movaps xmm0,[eax];
mov eax,[r];
movaps xmm1, [eax];
cmpps xmm0, xmm1, 1;
movmskps eax, xmm0;
mov flag, eax;
mov eax,[l1];
movaps xmm0,[eax];
cmpps xmm0, xmm1, 1;
movmskps eax, xmm0;
mov flag1, eax;
}
return flag == 15 && flag1 == 0;
}
int _tmain( int argc, _TCHAR * argv[])
{
int COUNT = 1000000;
Rect l = {0,0,100,100};
Rect* ls = new Rect[COUNT];
for ( int cnt =0; cnt <COUNT; cnt++ )
{
ls[cnt].x = rand()%10+1;
ls[cnt].y = rand()%10+1;
ls[cnt].right = 10;
ls[cnt].bottom = 10;
}
//l的左上点
Rect ll0 = {0.0f,0.0f,0.0f,0.0f};
//l的右下点
Rect ll1 = {100.0f,100.0f,100.0f,100.0f};
LARGE_INTEGER start,end,fre;
::QueryPerformanceCounter(&start);
::QueryPerformanceFrequency(&fre);
bool res;
for ( int cnt =0; cnt <COUNT; cnt++ )
{
res = RectAndRect(&ll0,&ll1,ls+cnt);
}
::QueryPerformanceCounter(&end);
double ress = double(end.QuadPart - start.QuadPart)/(double)fre.QuadPart;
std::cout<<ress<<std::endl;
std::cout<<res<<std::endl;
delete[] ls;
return 0;
}