1 Star 2 Fork 2

aczz / mnist

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pixel_benchmark.h 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
aczz 提交于 2021-03-08 22:47 . benchmark parse efficiency on windows
#ifndef PIXEL_BENCHMARK_H
#define PIXEL_BENCHMARK_H
#include <time.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32
//--------------------------------------------------------------------------------
// declaration
//--------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
static inline double pixel_get_current_time();
#ifdef __cplusplus
}
#endif
//--------------------------------------------------------------------------------
// implementation
//--------------------------------------------------------------------------------
#ifdef _WIN32
static inline double pixel_get_current_time()
{
LARGE_INTEGER freq;
LARGE_INTEGER pc;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&pc);
return pc.QuadPart * 1000.0 / freq.QuadPart;
}
#else // _WIN32
// expected to be more accurate
static inline double pixel_get_current_time()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000.0 + ts.tv_nsec/1000000.0;
}
// not that accurate
static inline double pixel_get_current_time2()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0;
}
#endif // _WIN32
#endif // PIXEL_BENCHMARK_H
1
https://gitee.com/aczz/mnist.git
git@gitee.com:aczz/mnist.git
aczz
mnist
mnist
master

搜索帮助