1 #ifdef PLATFORM_WINDOWS
2 #include "IncludeWindows.h"
4 #if defined(__linux__) || defined(__APPLE__)
8 #include "UMicroseconds.h"
11 UMicroseconds& UMicroseconds::ReadTime()
13 // Note: g_get_monotonic_time() may be a viable alternative
14 // (it is on Linux and OSX); if not, this code should really go into libpbd
15 #ifdef PLATFORM_WINDOWS
16 LARGE_INTEGER Frequency, Count ;
18 QueryPerformanceFrequency(&Frequency) ;
19 QueryPerformanceCounter(&Count);
20 theTime = uint64_t((Count.QuadPart * 1000000.0 / Frequency.QuadPart));
22 #elif defined __MACH__ // OSX, BSD..
26 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
27 clock_get_time(cclock, &mts);
28 mach_port_deallocate(mach_task_self(), cclock);
29 theTime = (uint64_t)mts.tv_sec * 1e6 + (uint64_t)mts.tv_nsec / 1000;
34 clock_gettime(CLOCK_MONOTONIC, ts);
35 theTime = (uint64_t)ts.tv_sec * 1e6 + (uint64_t)buf.tv_nsec / 1000;
42 Removed in favor of the posix implementation.
44 uint32_t UMicroseconds::hi() {return reinterpret_cast<UnsignedWide*>(&theTime)->hi;}
45 uint32_t UMicroseconds::lo() {return reinterpret_cast<UnsignedWide*>(&theTime)->lo;}
48 void UMicrosecondsAccumulator::Start()
50 m_start_time.ReadTime();
53 void UMicrosecondsAccumulator::Stop()
55 UMicroseconds stop_time;
57 m_accumulator += stop_time.GetNativeTime() - m_start_time.GetNativeTime();
60 void UMicrosecondsAccumulator::Clear()
66 UMicroseconds UMicrosecondsAccumulator::GetAccumulatedTime() const
71 UMicrosecondsAccumulator& UMicrosecondsAccumulator::operator+=(const UMicrosecondsAccumulator& inaccum_to_add)
73 m_accumulator += inaccum_to_add.GetAccumulatedTime();