⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 88199 in webkit


Ignore:
Timestamp:
Jun 6, 2011, 4:04:58 PM (15 years ago)
Author:
simonjam@chromium.org
Message:

2011-06-06 James Simonsen <simonjam@chromium.org>

Reviewed by James Robinson.

Add monotonicallyIncreasingTime() to get monotonically increasing time
https://bugs.webkit.org/show_bug.cgi?id=37743

  • wtf/CurrentTime.cpp: Add monotonicallyIncreasingTime() for mac and a fallback implementation that just wraps currentTime(). (WTF::monotonicallyIncreasingTime):
  • wtf/CurrentTime.h: Add monotonicallyIncreasingTime().

2011-06-06 James Simonsen <simonjam@chromium.org>

Reviewed by James Robinson.

Add monotonicallyIncreasingTime() to get monotonically increasing time
https://bugs.webkit.org/show_bug.cgi?id=37743

  • platform/chromium/SystemTimeChromium.cpp: (WebCore::monotonicallyIncreasingTime): Add primitive monotonicallyIncreasingTime() which just wraps currentTime().
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r88151 r88199  
     12011-06-06  James Simonsen  <simonjam@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        Add monotonicallyIncreasingTime() to get monotonically increasing time
     6        https://bugs.webkit.org/show_bug.cgi?id=37743
     7
     8        * wtf/CurrentTime.cpp: Add monotonicallyIncreasingTime() for mac and a fallback implementation that just wraps currentTime().
     9        (WTF::monotonicallyIncreasingTime):
     10        * wtf/CurrentTime.h: Add monotonicallyIncreasingTime().
     11
    1122011-06-06  Alexandru Chiculita  <achicu@adobe.com>
    213
  • trunk/Source/JavaScriptCore/wtf/CurrentTime.cpp

    r79434 r88199  
    3434#include "CurrentTime.h"
    3535
    36 #if OS(WINDOWS)
     36#if PLATFORM(MAC)
     37#include <mach/mach_time.h>
     38#include <sys/time.h>
     39#elif OS(WINDOWS)
    3740
    3841// Windows is first since we want to use hires timers, despite USE(CF)
     
    295298#endif
    296299
     300#if PLATFORM(MAC)
     301
     302double monotonicallyIncreasingTime()
     303{
     304    // Based on listing #2 from Apple QA 1398.
     305    static mach_timebase_info_data_t timebaseInfo;
     306    if (!timebaseInfo.denom) {
     307        kern_return_t kr = mach_timebase_info(&timebaseInfo);
     308        ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
     309    }
     310    return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom);
     311}
     312
     313#else
     314
     315double monotonicallyIncreasingTime()
     316{
     317    static double lastTime = 0;
     318    double currentTimeNow = currentTime();
     319    if (currentTimeNow < lastTime)
     320        return lastTime;
     321    lastTime = currentTimeNow;
     322    return currentTimeNow;
     323}
     324
     325#endif
     326
    297327} // namespace WTF
  • trunk/Source/JavaScriptCore/wtf/CurrentTime.h

    r77087 r88199  
    5959}
    6060
     61// Provides a monotonically increasing time in seconds since an arbitrary point in the past.
     62// On unsupported platforms, this function only guarantees the result will be non-decreasing.
     63double monotonicallyIncreasingTime();
     64
    6165} // namespace WTF
    6266
     
    6468using WTF::currentTimeMS;
    6569using WTF::getLocalTime;
     70using WTF::monotonicallyIncreasingTime;
    6671
    6772#endif // CurrentTime_h
    68 
  • trunk/Source/WebCore/ChangeLog

    r88198 r88199  
     12011-06-06  James Simonsen  <simonjam@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        Add monotonicallyIncreasingTime() to get monotonically increasing time
     6        https://bugs.webkit.org/show_bug.cgi?id=37743
     7
     8        * platform/chromium/SystemTimeChromium.cpp:
     9        (WebCore::monotonicallyIncreasingTime): Add primitive monotonicallyIncreasingTime() which just wraps currentTime().
     10
    1112011-06-06  Emil A Eklund  <eae@chromium.org>
    212
  • trunk/Source/WebCore/platform/chromium/SystemTimeChromium.cpp

    r76340 r88199  
    3434#include "NotImplemented.h"
    3535#include "PlatformBridge.h"
     36#include <wtf/CurrentTime.h>
    3637
    3738namespace WebCore {
     
    4142{
    4243    return PlatformBridge::currentTime();
     44}
     45
     46double monotonicallyIncreasingTime()
     47{
     48    static double lastTime = 0;
     49    double currentTimeNow = currentTime();
     50    if (currentTimeNow < lastTime)
     51        return lastTime;
     52    lastTime = currentTimeNow;
     53    return currentTimeNow;
    4354}
    4455
Note: See TracChangeset for help on using the changeset viewer.