| 790 | |
| 791 | |
| 792 | double getThreadTime() { |
| 793 | #if defined ARCH_LIN |
| 794 | struct timespec ts; |
| 795 | clockid_t cid; |
| 796 | pthread_getcpuclockid(pthread_self(), &cid); |
| 797 | clock_gettime(cid, &ts); |
| 798 | return ts.tv_sec + ts.tv_nsec * 1e-9; |
| 799 | #elif defined ARCH_MAC |
| 800 | mach_port_t thread = mach_thread_self(); |
| 801 | mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; |
| 802 | thread_basic_info_data_t info; |
| 803 | kern_return_t kr = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &count); |
| 804 | if (kr != KERN_SUCCESS || (info.flags & TH_FLAGS_IDLE) != 0) |
| 805 | return 0.0; |
| 806 | return info.user_time.seconds + info.user_time.microseconds * 1e-6; |
| 807 | #elif defined ARCH_WIN |
| 808 | FILETIME creationTime; |
| 809 | FILETIME exitTime; |
| 810 | FILETIME kernelTime; |
| 811 | FILETIME userTime; |
| 812 | if (GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime) == 0) |
| 813 | return 0.0; |
| 814 | return ((uint64_t(userTime.dwHighDateTime) << 32) + userTime.dwLowDateTime) * 1e-7; |
| 815 | #else |
| 816 | return 0.0; |
| 817 | #endif |
| 818 | } |
| 819 | |
| 820 | |
| 821 | void sleep(double time) { |
nothing calls this directly
no outgoing calls
no test coverage detected