#pragma once
#if defined(_WIN32)
#include<sys/timeb.h>
#if defined(__UNIX__)||defined(__APPLE__)
#include<time.h>
#endif
typedef long long long_time_t;
long_time_t TimeInMillisecond(void) {
#if defined(_WIN32)
struct timeb time_buffer;
ftime(&time_buffer);
return time_buffer.time*1000LL+time_buffer.millitm;
#elif defined(__UNIX__)||defined(__APPLE__)
struct timeval time_value;
gettimeofday(&time_buffer,NULL);
return time_buffer.tv_sec*1000LL+time_buffer.tv_usec/1000;
#elif defined(__STDC__)&&__STDC__VERSION__==201112L
struct timespec timespec_value;
timespec_get(×pec_value,TIME_UTC);
return timespec_value.tv_sec*1000LL+timespec_value.tv_nsec/1000;
#else
time_t current_time = time(NULL);
return current_time*1000LL;
#endif
}
#endif
#include<stdio.h>
#include<time.h>
#include"../include/io_utils.h"
#include"../include/time_utils.h"
int main()
{
clock_t start_time = clock();
for(int i = 0;i<100;++i)
printf("hello world!");
clock_t end_time = clock();
PRINT_DOUBLE((end_time-start_time)*1.0/CLOCKS_PER_SEC);
return 0;
}
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。