Changeset 48736 in webkit for trunk/JavaScriptCore/jsc.cpp


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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.