Changeset 48736 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 24, 2009, 3:00:44 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r48733 r48736 1 2009-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 1 15 2009-09-24 Mark Rowe <[email protected]> 2 16 -
trunk/JavaScriptCore/jsc.cpp
r46598 r48736 25 25 #include "BytecodeGenerator.h" 26 26 #include "Completion.h" 27 #include "CurrentTime.h" 27 28 #include "InitializeThreading.h" 28 29 #include "JSArray.h" … … 119 120 120 121 private: 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; 132 124 }; 133 125 134 126 void StopWatch::start() 135 127 { 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(); 144 129 } 145 130 146 131 void StopWatch::stop() 147 132 { 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(); 156 134 } 157 135 158 136 long StopWatch::getElapsedMS() 159 137 { 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); 168 139 } 169 140 -
trunk/JavaScriptCore/runtime/TimeoutChecker.cpp
r41126 r48736 36 36 #if PLATFORM(DARWIN) 37 37 #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) 45 39 #include <windows.h> 46 #endif 47 48 #if PLATFORM(QT) 49 #include <QDateTime> 40 #else 41 #include "CurrentTime.h" 50 42 #endif 51 43 … … 76 68 77 69 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();86 70 #elif PLATFORM(WIN_OS) 87 71 union { … … 98 82 return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000; 99 83 #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; 101 86 #endif 102 87 }
Note:
See TracChangeset
for help on using the changeset viewer.