Changeset 48736 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 24, 2009, 3:00:44 PM (16 years ago)
Author:
[email protected]
Message:

2009-09-24 Yong Li <[email protected]>

Reviewed by Adam Barth.

Replace platform-dependent code with WTF::currentTime()
https://bugs.webkit.org/show_bug.cgi?id=29148

  • jsc.cpp: (StopWatch::start): (StopWatch::stop): (StopWatch::getElapsedMS):
  • runtime/TimeoutChecker.cpp: (JSC::getCPUTime):
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r48733 r48736  
     12009-09-24  Yong Li  <[email protected]>
     2
     3        Reviewed by Adam Barth.
     4
     5        Replace platform-dependent code with WTF::currentTime()
     6        https://bugs.webkit.org/show_bug.cgi?id=29148
     7
     8        * jsc.cpp:
     9        (StopWatch::start):
     10        (StopWatch::stop):
     11        (StopWatch::getElapsedMS):
     12        * runtime/TimeoutChecker.cpp:
     13        (JSC::getCPUTime):
     14
    1152009-09-24  Mark Rowe  <[email protected]>
    216
  • trunk/JavaScriptCore/jsc.cpp

    r46598 r48736  
    2525#include "BytecodeGenerator.h"
    2626#include "Completion.h"
     27#include "CurrentTime.h"
    2728#include "InitializeThreading.h"
    2829#include "JSArray.h"
     
    119120
    120121private:
    121 #if PLATFORM(QT)
    122     uint m_startTime;
    123     uint m_stopTime;
    124 #elif PLATFORM(WIN_OS)
    125     DWORD m_startTime;
    126     DWORD m_stopTime;
    127 #else
    128     // Windows does not have timeval, disabling this class for now (bug 7399)
    129     timeval m_startTime;
    130     timeval m_stopTime;
    131 #endif
     122    double m_startTime;
     123    double m_stopTime;
    132124};
    133125
    134126void StopWatch::start()
    135127{
    136 #if PLATFORM(QT)
    137     QDateTime t = QDateTime::currentDateTime();
    138     m_startTime = t.toTime_t() * 1000 + t.time().msec();
    139 #elif PLATFORM(WIN_OS)
    140     m_startTime = timeGetTime();
    141 #else
    142     gettimeofday(&m_startTime, 0);
    143 #endif
     128    m_startTime = currentTime();
    144129}
    145130
    146131void StopWatch::stop()
    147132{
    148 #if PLATFORM(QT)
    149     QDateTime t = QDateTime::currentDateTime();
    150     m_stopTime = t.toTime_t() * 1000 + t.time().msec();
    151 #elif PLATFORM(WIN_OS)
    152     m_stopTime = timeGetTime();
    153 #else
    154     gettimeofday(&m_stopTime, 0);
    155 #endif
     133    m_stopTime = currentTime();
    156134}
    157135
    158136long StopWatch::getElapsedMS()
    159137{
    160 #if PLATFORM(WIN_OS) || PLATFORM(QT)
    161     return m_stopTime - m_startTime;
    162 #else
    163     timeval elapsedTime;
    164     timersub(&m_stopTime, &m_startTime, &elapsedTime);
    165 
    166     return elapsedTime.tv_sec * 1000 + lroundf(elapsedTime.tv_usec / 1000.0f);
    167 #endif
     138    return static_cast<long>((m_stopTime - m_startTime) * 1000);
    168139}
    169140
  • trunk/JavaScriptCore/runtime/TimeoutChecker.cpp

    r41126 r48736  
    3636#if PLATFORM(DARWIN)
    3737#include <mach/mach.h>
    38 #endif
    39 
    40 #if HAVE(SYS_TIME_H)
    41 #include <sys/time.h>
    42 #endif
    43 
    44 #if PLATFORM(WIN_OS)
     38#elif PLATFORM(WIN_OS)
    4539#include <windows.h>
    46 #endif
    47 
    48 #if PLATFORM(QT)
    49 #include <QDateTime>
     40#else
     41#include "CurrentTime.h"
    5042#endif
    5143
     
    7668   
    7769    return time;
    78 #elif HAVE(SYS_TIME_H)
    79     // FIXME: This should probably use getrusage with the RUSAGE_THREAD flag.
    80     struct timeval tv;
    81     gettimeofday(&tv, 0);
    82     return tv.tv_sec * 1000 + tv.tv_usec / 1000;
    83 #elif PLATFORM(QT)
    84     QDateTime t = QDateTime::currentDateTime();
    85     return t.toTime_t() * 1000 + t.time().msec();
    8670#elif PLATFORM(WIN_OS)
    8771    union {
     
    9882    return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000;
    9983#else
    100 #error Platform does not have getCurrentTime function
     84    // FIXME: We should return the time the current thread has spent executing.
     85    return currentTime() * 1000;
    10186#endif
    10287}
Note: See TracChangeset for help on using the changeset viewer.