大神,求救!!为什么delete要比new慢?
class CMatrix1
{
public:
double matrix[16];
CMatrix1()
{
}
~CMatrix1()
{
};
};
//测试
{
DWORD tickCount = 0;
char tempStr[1024] = {0};
//1. 赋值
tickCount = GetTickCount();
std::vector<CMatrix1*> matrixList;
matrixList.resize(264633);
for (int i = 0; i < 264633; i ++)
{
CMatrix1 *des = new CMatrix1;
matrixList[i] = des;
}
tickCount = GetTickCount() - tickCount;
memset(tempStr,0,1024);
sprintf(tempStr,"segment paras new: %d s", tickCount/1000);
OutputLogString(tempStr); //写文件函数,用于调试输出
//2. 析构
tickCount = GetTickCount();
for (int i = 264632; i >=0 ; i --)
{
delete matrixList[i];
}
tickCount = GetTickCount() - tickCount;
memset(tempStr,0,1024);
sprintf(tempStr,"segment paras delete: %d s", tickCount/1000);
OutputLogString(tempStr);
}