use macro NANOSEC MICROSEC

This commit is contained in:
Cloud Wu
2014-04-22 19:52:19 +08:00
parent 277bc79fb7
commit 94f6c63849

View File

@@ -10,6 +10,7 @@
#endif #endif
#define NANOSEC 1000000000 #define NANOSEC 1000000000
#define MICROSEC 1000000
static double static double
get_time() { get_time() {
@@ -20,7 +21,7 @@ get_time() {
int sec = ti.tv_sec & 0xffff; int sec = ti.tv_sec & 0xffff;
int nsec = ti.tv_nsec; int nsec = ti.tv_nsec;
return (double)sec + (double)nsec / 1000000000; return (double)sec + (double)nsec / NANOSEC;
#else #else
struct task_thread_times_info aTaskInfo; struct task_thread_times_info aTaskInfo;
mach_msg_type_number_t aTaskInfoCount = TASK_THREAD_TIMES_INFO_COUNT; mach_msg_type_number_t aTaskInfoCount = TASK_THREAD_TIMES_INFO_COUNT;
@@ -29,7 +30,7 @@ get_time() {
int sec = aTaskInfo.user_time.seconds & 0xffff; int sec = aTaskInfo.user_time.seconds & 0xffff;
int msec = aTaskInfo.user_time.microseconds; int msec = aTaskInfo.user_time.microseconds;
return (double)sec + (double)msec / 1000000; return (double)sec + (double)msec / MICROSEC;
#endif #endif
} }