⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eclock.h

📁 实现了poll/epoll/devpoll等C++封装
💻 H
字号:
/*-------------------------------------------------------------------------- Portable clock functions.--------------------------------------------------------------------------*/#ifndef eclock_h#define eclock_h//#include "dprint.h"#include <time.h>#include <sys/time.h>#include <unistd.h>/*-------------------------------------------------------------------------- Get current time, in clock ticks. Return type is int.--------------------------------------------------------------------------*/#define eclock_HERTZ 10000#define eclock_TICKSPERUSEC 100extern struct timeval eclock_timeval;#define eclock() (gettimeofday(&eclock_timeval, NULL), \	((int)((eclock_timeval.tv_sec * eclock_HERTZ) + (eclock_timeval.tv_usec / eclock_TICKSPERUSEC))))/*-------------------------------------------------------------------------- Get number of clock ticks per second, in hertz.  This evaluates to a  system call, so call it just once at the start of the program. Return type is int.--------------------------------------------------------------------------*/#define eclock_hertz() eclock_HERTZ/*-------------------------------------------------------------------------- Safe way to compare to eclock() values to see which is after the other. Assumes the largest interval to be compared is one half the maximum representable in a long. Returns true if time a is after time b.--------------------------------------------------------------------------*///#define eclock_after(a, b) (((long)((a)-(b))) > 0)inline bool eclock_after(clock_t a, clock_t b){	long diff = (long) (a - b);	//DPRINT(("eclock_after(%d, %d): diff %d\n", a, b, diff));	return (diff > 0);}/*-------------------------------------------------------------------------- Safe way to compare to eclock() values to see which is after the other. Assumes the largest interval to be compared is one half the maximum representable in a long. Returns true if time a is before time b.--------------------------------------------------------------------------*///#define eclock_before(a, b) (((long)((a)-(b))) < 0)inline bool eclock_before(clock_t a, clock_t b){	long diff = (long) (a - b);	//DPRINT(("eclock_before(%d, %d): diff %d\n", a, b, diff));	return (diff < 0);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -