const int COUNT = 100;void TestArray(){ int tmpArray[COUNT]; DWORD iBegin = GetTickCount(); for (int i=0; i<100000; ++i) { tmpArray[i%COUNT] = i; } DWORD iEnd = GetTickCount(); std::cout << "tmpArray:" << iEnd - iBegin << std::endl;}void TestVector(){ std::vector<int> tmpVec; for (int i=0; i<COUNT; ++i) { tmpVec.push_back(i); } DWORD iBegin = GetTickCount(); for (int i=0; i<100000; ++i) { tmpVec.at(i%COUNT) = i; } DWORD iEnd = GetTickCount(); std::cout << "vector:" << iEnd - iBegin << std::endl;}void TestMap(){ std::map<int, int> tmpMap; for (int i=0; i<COUNT; ++i) { tmpMap[i] = 0; } DWORD iBegin = GetTickCount(); for (int i=0; i<100000; ++i) { tmpMap[i%COUNT] = i; } DWORD iEnd = GetTickCount(); std::cout << "map:" << iEnd - iBegin << std::endl;}void TestVecMap(){ TestArray(); TestVector(); TestMap(); TestArray(); TestVector(); TestMap(); TestArray(); TestVector(); TestMap(); TestArray(); TestVector(); TestMap();} 测试结果如下: 2010-10-30 10:52:00