Commit 7de48b2e authored by timothy@apple.com's avatar 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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c3f9d123
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
......
......@@ -274,8 +274,14 @@ 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;
}
......
......@@ -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*);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment