我有以下代码段。对于大小为176000的矢量,循环最多需要8分钟才能执行。我不知道什么是采取了这么多时间性能调整
XEPComBSTR bstrSetWithIdsAsString; //Wrapper class for BSTR
std::vector<__int64>::const_iterator it;
for(it = vecIds.begin();
it != vecIds.end();
it++)
{
__int64 i64Id = (*it);
__int64 i64OID = XPtFunctions::GetOID(i64Id);
// set ',' between two set members
if (it != vecIds.begin())
bstrSetWithIdsAsString.Append(XEPComBSTR(L","));
wchar_t buf[20];
_i64tow_s(i64OID, buf, 20, 10);
bstrSetWithIdsAsString.Append(buf);
}
__int64 GetOID(const __int64 &i64Id)
{
__int64 numId = i64Id;
numId <<= 16;
numId >>= 16;
return numId;
}
我通常会介绍一个程序,以确定它为什么不执行,因为我认为它应该... – justin 2011-02-23 12:16:16
8分钟在哪种情况下?你是否在编译优化?您使用的是哪种编译器,对于MSVC,您是否禁用了Secure STL功能? – jalf 2011-02-23 12:19:39
@jalf没有优化设置。我正在使用VC9 – 2011-02-23 12:26:02