Make the profiler use higher than millisecond resolution time-stamps.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2008 13:58:12 +0000 (13:58 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 May 2008 13:58:12 +0000 (13:58 +0000)
Reviewed by Kevin McCullough.

* kjs/DateMath.cpp:
(KJS::getCurrentUTCTime): Call getCurrentUTCTimeWithMicroseconds and
floor the result.
(KJS::getCurrentUTCTimeWithMicroseconds): Copied from the previous
implementation of getCurrentUTCTime without the floor call.
* kjs/DateMath.h: Addded getCurrentUTCTimeWithMicroseconds.
* profiler/ProfileNode.cpp:
(KJS::ProfileNode::ProfileNode): Use getCurrentUTCTimeWithMicroseconds.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@33930 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/DateMath.cpp
JavaScriptCore/kjs/DateMath.h
JavaScriptCore/profiler/ProfileNode.cpp

index b2f0734..e2fdfec 100644 (file)
@@ -1,5 +1,20 @@
 2008-05-19  Timothy Hatcher  <timothy@apple.com>
 
+        Make the profiler use higher than millisecond resolution time-stamps.
+
+        Reviewed by Kevin McCullough.
+
+        * kjs/DateMath.cpp:
+        (KJS::getCurrentUTCTime): Call getCurrentUTCTimeWithMicroseconds and
+        floor the result.
+        (KJS::getCurrentUTCTimeWithMicroseconds): Copied from the previous
+        implementation of getCurrentUTCTime without the floor call.
+        * kjs/DateMath.h: Addded getCurrentUTCTimeWithMicroseconds.
+        * profiler/ProfileNode.cpp:
+        (KJS::ProfileNode::ProfileNode): Use getCurrentUTCTimeWithMicroseconds.
+
+2008-05-19  Timothy Hatcher  <timothy@apple.com>
+
         Fixes a bug in the profiler where call and apply would show up
         and double the time spent in a function. We don't want to show call
         and apply at all in the profiles. This change excludes them.
index 3c0d55c..7f05b98 100644 (file)
@@ -275,7 +275,13 @@ static int dateToDayInYear(int year, int month, int day)
 
 double getCurrentUTCTime()
 {
+    return floor(getCurrentUTCTimeWithMicroseconds());
+}
+
+double getCurrentUTCTimeWithMicroseconds()
+{
 #if PLATFORM(WIN_OS)
+    // FIXME: the implementation for Windows is only millisecond resolution.
 #if COMPILER(BORLAND)
     struct timeb timebuffer;
     ftime(&timebuffer);
@@ -287,7 +293,7 @@ double getCurrentUTCTime()
 #else
     struct timeval tv;
     gettimeofday(&tv, 0);
-    double utc = floor(tv.tv_sec * msPerSecond + tv.tv_usec / 1000);
+    double utc = tv.tv_sec * msPerSecond + tv.tv_usec / 1000.0;
 #endif
     return utc;
 }
index 8082096..8fa009b 100644 (file)
@@ -55,6 +55,7 @@ double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);
 double getUTCOffset();
 int equivalentYearForDST(int year);
 double getCurrentUTCTime();
+double getCurrentUTCTimeWithMicroseconds();
 void getLocalTime(const time_t*, tm*);
 
 
index 8a60da8..508230d 100644 (file)
@@ -44,12 +44,12 @@ ProfileNode::ProfileNode(const UString& name)
     , m_selfPercent (0.0)
     , m_numberOfCalls(0)
 {
-    m_startTime = getCurrentUTCTime();
+    m_startTime = getCurrentUTCTimeWithMicroseconds();
 }
 
 void ProfileNode::willExecute()
 {
-    m_startTime = getCurrentUTCTime();
+    m_startTime = getCurrentUTCTimeWithMicroseconds();
 }
 
 // We start at the end of stackNames and work our way forwards since the names are in 
@@ -220,7 +220,7 @@ void ProfileNode::sortFileNameAscending()
 
 void ProfileNode::endAndRecordCall()
 {
-    m_totalTime += getCurrentUTCTime() - m_startTime;
+    m_totalTime += getCurrentUTCTimeWithMicroseconds() - m_startTime;
     m_startTime = 0.0;
 
     ++m_numberOfCalls;