Ignore:
Timestamp:
May 22, 2008, 9:32:47 PM (17 years ago)
Author:
Adam Roben
Message:

Implement sub-millisecond profiling on Windows

Reviewed by Kevin McCullough.

  • profiler/ProfileNode.cpp: (KJS::getCount): Added. On Windows, we use QueryPerformanceCounter. On other platforms, we use getCurrentUTCTimeWithMicroseconds. (KJS::ProfileNode::endAndRecordCall): Use getCount instead of getCurrentUTCTimeWithMicroseconds. (KJS::ProfileNode::startTimer): Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/profiler/ProfileNode.cpp

    r34043 r34048  
    3535#include <stdio.h>
    3636
     37#if PLATFORM(WIN_OS)
     38#include <windows.h>
     39#endif
     40
    3741namespace KJS {
    3842
    3943static const char* NonJSExecution = "(idle)";
     44
     45static double getCount()
     46{
     47#if PLATFORM(WIN_OS)
     48    static LARGE_INTEGER frequency = {0};
     49    if (!frequency.QuadPart)
     50        QueryPerformanceFrequency(&frequency);
     51    LARGE_INTEGER counter;
     52    QueryPerformanceCounter(&counter);
     53    return static_cast<double>(counter.QuadPart) / frequency.QuadPart;
     54#else
     55    return getCurrentUTCTimeWithMicroseconds();
     56#endif
     57}
    4058
    4159ProfileNode::ProfileNode(const CallIdentifier& callIdentifier, ProfileNode* headNode, ProfileNode* parentNode)
     
    298316void ProfileNode::endAndRecordCall()
    299317{
    300     m_actualTotalTime += getCurrentUTCTimeWithMicroseconds() - m_startTime;
     318    m_actualTotalTime += getCount() - m_startTime;
    301319    m_startTime = 0.0;
    302320
     
    307325{
    308326    if (!m_startTime)
    309         m_startTime = getCurrentUTCTimeWithMicroseconds();
     327        m_startTime = getCount();
    310328}
    311329
Note: See TracChangeset for help on using the changeset viewer.