using namespace std::chrono;
void Test(size_t size, size_t cpy_times)
{
printf("copy(size=%d bytes, loops=%d): ", size, cpy_times);
char* src = new char[size]();
char* dst = new char[size]();
auto p1 = high_resolution_clock::now();
for (int i = 0; i < cpy_times; ++i)
{
memcpy(dst, src, size);
}
auto p2 = high_resolution_clock::now();
printf("time: %d ms\n", duration_cast<milliseconds>(p2 - p1).count());
delete[] src;
delete[] dst;
}
int main(int argc, char* argv[])
{
Test(4096, 0x80000);
Test(8192, 0x40000);
Test(1024 * 500, 0x1000);
Test(1024 * 1024 * 1, 0x800);
Test(1024 * 1024 * 2, 0x400);
Test(1024 * 1024 * 4, 0x200);
Test(1024 * 1024 * 24, 0x100);
}
【 在 mountainlion 的大作中提到: 】
: 方便发测试代码看下吗
:
--
FROM 101.228.56.*