diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-24 20:17:24 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-24 20:17:24 +0000 |
commit | 86e05bdb09ccd6a0530232c0ae1cf64d8200d62f (patch) | |
tree | bc4c03c8446062742d52573b424963ca87dc4927 | |
parent | a1c1272a4ed196c06088671c31adf5a155a493ed (diff) | |
download | src-86e05bdb09ccd6a0530232c0ae1cf64d8200d62f.tar.gz |
Revert of Add nanosecond timer. (https://codereview.chromium.org/250243002/)
Reason for revert:
breaks EVERYTHING
Original issue's description:
> Add nanosecond timer.
>
> I've been finding it hard to get enough resolution out of our existing timers when measuring really tiny pictures.
>
> BUG=skia:2378
>
> Committed: http://code.google.com/p/skia/source/detail?r=14362
R=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org
TBR=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:2378
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/258703002
git-svn-id: http://skia.googlecode.com/svn/trunk/src@14364 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | ports/SkTime_Unix.cpp | 40 | ||||
-rw-r--r-- | ports/SkTime_win.cpp | 8 |
2 files changed, 14 insertions, 34 deletions
diff --git a/ports/SkTime_Unix.cpp b/ports/SkTime_Unix.cpp index cdf7f3d9..f519a69d 100644 --- a/ports/SkTime_Unix.cpp +++ b/ports/SkTime_Unix.cpp @@ -12,8 +12,10 @@ #include <sys/time.h> #include <time.h> -void SkTime::GetDateTime(DateTime* dt) { - if (dt) { +void SkTime::GetDateTime(DateTime* dt) +{ + if (dt) + { time_t m_time; time(&m_time); struct tm* tstruct; @@ -29,33 +31,9 @@ void SkTime::GetDateTime(DateTime* dt) { } } -#ifdef __MACH__ -# include <mach/mach_time.h> - -namespace { - -struct ConversionFactor { - ConversionFactor() { - mach_timebase_info_data_t timebase; - mach_timebase_info(&timebase); - toNanos = (double) timebase.numer / timebase.denom; - } - double toNanos; -}; - -} // namespace - -SkNSec SkTime::GetNSecs() { - static ConversionFactor convert; // Since already know we're on Mac, this is threadsafe. - return mach_absolute_time() * convert.toNanos; +SkMSec SkTime::GetMSecs() +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds } - -#else // Linux, presumably all others too - -SkNSec SkTime::GetNSecs() { - struct timespec time; - clock_gettime(CLOCK_MONOTONIC, &time); - return (SkNSec)(time.tv_sec * 1000000000 + time.tv_nsec); -} - -#endif diff --git a/ports/SkTime_win.cpp b/ports/SkTime_win.cpp index a48a69e8..37af9f29 100644 --- a/ports/SkTime_win.cpp +++ b/ports/SkTime_win.cpp @@ -9,7 +9,8 @@ #include "SkTime.h" -void SkTime::GetDateTime(DateTime* dt) { +void SkTime::GetDateTime(DateTime* dt) +{ if (dt) { SYSTEMTIME st; @@ -25,12 +26,13 @@ void SkTime::GetDateTime(DateTime* dt) { } } -SkNSec SkTime::GetNSecs() { +SkMSec SkTime::GetMSecs() +{ FILETIME ft; LARGE_INTEGER li; GetSystemTimeAsFileTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; __int64 t = li.QuadPart; /* In 100-nanosecond intervals */ - return (SkMSec)(t * 100); + return (SkMSec)(t / 10000); /* In milliseconds */ } |