/****************************************************************************
@File Name: test.cpp
@Author: wangzhicheng
@mail: 2363702560@qq.com
@Created Time: Sat 11 Feb 2017 08:23:01 PM CST
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <chrono>
using namespace std;
using namespace chrono;
int main()
{
char buf[1024 * 1024];
const int N = 100000;
auto mystart = system_clock::now();
for(int i = 0;i < N;i++)
{
bzero(buf, 0); // bzero is much more faster than memset
// memset(buf, 0, sizeof buf);
buf[1024] = '1';
}
auto myend = system_clock::now();
auto duration = duration_cast<microseconds>(myend - mystart);
cout << static_cast<double>(duration.count()) * microseconds::period::num / microseconds::period::den << endl;
return 0;
}
time elapse
最新推荐文章于 2023-12-10 17:41:14 发布