c++ - Performance tuning -
i have following code segment . vector of size 176000 loop takes upto 8 minutes execute . not sure taking time
xepcombstr bstrsetwithidsasstring; //wrapper class bstr std::vector<__int64>::const_iterator it; for(it = vecids.begin(); != vecids.end(); it++) { __int64 i64id = (*it); __int64 i64oid = xptfunctions::getoid(i64id); // set ',' between 2 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; }
i think bottleneck append function. see, string has allocated memory inside, , when try append won't fit, reallocates more memory, takes lot of time. try allocating necessary memory once in beginning. hth
Comments
Post a Comment