代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
int gettime(int i)
{
static struct timeval tv1;
struct timeval tv2;
if(i == 0)
{
gettimeofday(&tv1, NULL);
return 0;
}else
{
gettimeofday(&tv2, NULL);
return tv2.tv_sec * 1000000 + tv2.tv_usec - tv1.tv_sec * 1000000 - tv1.tv_usec;
}
}
/*#define SIZE (1024 * 1024 * 10)*/
#define SIZE (1024 * 1024 * 10)
long long buf[SIZE];
int main(int argc, char *argv[])
{
int i;
int time;
memset(buf, 0, SIZE * 8);
gettime(0);
for(i = 0; i < SIZE; i++)
{
buf[i] = i;
}
time = gettime(1);
printf("time1 = %d\n", time);
gettime(0);
for(i = 0; i < SIZE; i++)
{
buf[i] = i;
}
time = gettime(1);
printf("time2 = %d\n", time);
printf("speed: %dMB/S\n", SIZE * 8 / time);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。