#include "config.h"
#include "ProfileNode.h"
-#include "DateMath.h"
-#include "Profiler.h"
+#include "LegacyProfiler.h"
#include <stdio.h>
+#include <wtf/DateMath.h>
+#include <wtf/DataLog.h>
+#include <wtf/text/StringHash.h>
-#if PLATFORM(WIN_OS)
+#if OS(WINDOWS)
#include <windows.h>
#endif
+using namespace WTF;
+
namespace JSC {
static double getCount()
{
-#if PLATFORM(WIN_OS)
- static LARGE_INTEGER frequency = {0};
+#if OS(WINDOWS)
+ static LARGE_INTEGER frequency;
if (!frequency.QuadPart)
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
return static_cast<double>(counter.QuadPart) / frequency.QuadPart;
#else
- return getCurrentUTCTimeWithMicroseconds();
+ return currentTimeMS();
#endif
}
-ProfileNode::ProfileNode(const CallIdentifier& callIdentifier, ProfileNode* headNode, ProfileNode* parentNode)
- : m_callIdentifier(callIdentifier)
+ProfileNode::ProfileNode(ExecState* callerCallFrame, const CallIdentifier& callIdentifier, ProfileNode* headNode, ProfileNode* parentNode)
+ : m_callerCallFrame(callerCallFrame)
+ , m_callIdentifier(callIdentifier)
, m_head(headNode)
, m_parent(parentNode)
, m_nextSibling(0)
startTimer();
}
-ProfileNode::ProfileNode(ProfileNode* headNode, ProfileNode* nodeToCopy)
- : m_callIdentifier(nodeToCopy->callIdentifier())
+ProfileNode::ProfileNode(ExecState* callerCallFrame, ProfileNode* headNode, ProfileNode* nodeToCopy)
+ : m_callerCallFrame(callerCallFrame)
+ , m_callIdentifier(nodeToCopy->callIdentifier())
, m_head(headNode)
, m_parent(nodeToCopy->parent())
, m_nextSibling(0)
{
}
-ProfileNode* ProfileNode::willExecute(const CallIdentifier& callIdentifier)
+ProfileNode* ProfileNode::willExecute(ExecState* callerCallFrame, const CallIdentifier& callIdentifier)
{
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) {
if ((*currentChild)->callIdentifier() == callIdentifier) {
}
}
- RefPtr<ProfileNode> newChild = ProfileNode::create(callIdentifier, m_head ? m_head : this, this); // If this ProfileNode has no head it is the head.
+ RefPtr<ProfileNode> newChild = ProfileNode::create(callerCallFrame, callIdentifier, m_head ? m_head : this, this); // If this ProfileNode has no head it is the head.
if (m_children.size())
m_children.last()->setNextSibling(newChild.get());
m_children.append(newChild.release());
return next;
}
-void ProfileNode::sort(bool comparator(const RefPtr<ProfileNode>& , const RefPtr<ProfileNode>& ))
-{
- std::sort(childrenBegin(), childrenEnd(), comparator);
- resetChildrensSiblings();
-}
-
void ProfileNode::setTreeVisible(ProfileNode* node, bool visible)
{
ProfileNode* nodeParent = node->parent();
{
// Print function names
for (int i = 0; i < indentLevel; ++i)
- printf(" ");
+ dataLogF(" ");
- printf("Function Name %s %d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% VSelf %.3fms VTotal %.3fms Visible %s Next Sibling %s\n",
- functionName().UTF8String().c_str(),
+ dataLogF("Function Name %s %d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% VSelf %.3fms VTotal %.3fms Visible %s Next Sibling %s\n",
+ functionName().utf8().data(),
m_numberOfCalls, m_actualSelfTime, selfPercent(), m_actualTotalTime, totalPercent(),
m_visibleSelfTime, m_visibleTotalTime,
(m_visible ? "True" : "False"),
- m_nextSibling ? m_nextSibling->functionName().UTF8String().c_str() : "");
+ m_nextSibling ? m_nextSibling->functionName().utf8().data() : "");
++indentLevel;
// print the profiled data in a format that matches the tool sample's output.
double ProfileNode::debugPrintDataSampleStyle(int indentLevel, FunctionCallHashCount& countedFunctions) const
{
- printf(" ");
+ dataLogF(" ");
// Print function names
- const char* name = functionName().UTF8String().c_str();
+ const char* name = functionName().utf8().data();
double sampleCount = m_actualTotalTime * 1000;
if (indentLevel) {
for (int i = 0; i < indentLevel; ++i)
- printf(" ");
+ dataLogF(" ");
- countedFunctions.add(functionName().rep());
+ countedFunctions.add(functionName().impl());
- printf("%.0f %s\n", sampleCount ? sampleCount : 1, name);
+ dataLogF("%.0f %s\n", sampleCount ? sampleCount : 1, name);
} else
- printf("%s\n", name);
+ dataLogF("%s\n", name);
++indentLevel;
sumOfChildrensCount *= 1000; //
// Print remainder of samples to match sample's output
if (sumOfChildrensCount < sampleCount) {
- printf(" ");
+ dataLogF(" ");
while (indentLevel--)
- printf(" ");
+ dataLogF(" ");
- printf("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().UTF8String().c_str());
+ dataLogF("%.0f %s\n", sampleCount - sumOfChildrensCount, functionName().utf8().data());
}
return m_actualTotalTime;