Commit 9ff91796 authored by kmccullough@apple.com's avatar kmccullough@apple.com

2008-05-20 Kevin McCullough <kmccullough@apple.com>

        Reviewed by Tim.

        <rdar://problem/5950867> JSProfiler: Allow the profiler to "Focus" a
        profile node.
        - Implements focus by adding the idea of a profileNode being visible and
        adding the ability to reset all of the visible flags.

        * profiler/Profile.h: 
        (KJS::Profile::focus):
        * profiler/ProfileNode.cpp:
        (KJS::ProfileNode::ProfileNode): Initialize the visible flag.
        (KJS::ProfileNode::setTreeVisible): Set the visibility of this node and
        all of its descendents.
        (KJS::ProfileNode::focus): Determine if this node should be visible when
        focusing, if the functionName matches this node's function name or if any
        of this node's children are visible.
        (KJS::ProfileNode::restoreAll): Restore all nodes' visible flag.
        (KJS::ProfileNode::debugPrintData):
        * profiler/ProfileNode.h:
        (KJS::ProfileNode::visible):
        (KJS::ProfileNode::setVisible):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33965 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9a22c9c5
2008-05-20 Kevin McCullough <kmccullough@apple.com>
Reviewed by Tim.
<rdar://problem/5950867> JSProfiler: Allow the profiler to "Focus" a
profile node.
- Implements focus by adding the idea of a profileNode being visible and
adding the ability to reset all of the visible flags.
* profiler/Profile.h:
(KJS::Profile::focus):
* profiler/ProfileNode.cpp:
(KJS::ProfileNode::ProfileNode): Initialize the visible flag.
(KJS::ProfileNode::setTreeVisible): Set the visibility of this node and
all of its descendents.
(KJS::ProfileNode::focus): Determine if this node should be visible when
focusing, if the functionName matches this node's function name or if any
of this node's children are visible.
(KJS::ProfileNode::restoreAll): Restore all nodes' visible flag.
(KJS::ProfileNode::debugPrintData):
* profiler/ProfileNode.h:
(KJS::ProfileNode::visible):
(KJS::ProfileNode::setVisible):
2008-05-20 Timothy Hatcher <timothy@apple.com>
Fixes a couple performance issues with the profiler. Also fixes
......
......@@ -57,6 +57,9 @@ namespace KJS {
void sortCallsAscending() { m_callTree->sortCallsAscending(); }
void sortFunctionNameDescending() { m_callTree->sortFunctionNameDescending(); }
void sortFunctionNameAscending() { m_callTree->sortFunctionNameAscending(); }
void focus(const CallIdentifier& callIdentifier) { m_callTree->focus(callIdentifier); }
#ifndef NDEBUG
void debugPrintData() const;
void debugPrintDataSampleStyle() const;
......
......@@ -45,6 +45,7 @@ ProfileNode::ProfileNode(const CallIdentifier& callIdentifier)
, m_totalPercent (0.0)
, m_selfPercent (0.0)
, m_numberOfCalls(0)
, m_visible(true)
{
m_startTime = getCurrentUTCTimeWithMicroseconds();
}
......@@ -129,6 +130,14 @@ void ProfileNode::stopProfiling(double totalProfileTime, bool headProfileNode)
calculatePercentages(totalProfileTime);
}
void ProfileNode::setTreeVisible(bool visible)
{
m_visible = visible;
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
(*currentChild)->setTreeVisible(visible);
}
#pragma mark Sorting methods
static inline bool totalTimeDescendingComparator(const RefPtr<ProfileNode>& a, const RefPtr<ProfileNode>& b)
......@@ -235,6 +244,30 @@ void ProfileNode::sortFunctionNameAscending()
(*currentChild)->sortFunctionNameAscending();
}
bool ProfileNode::focus(const CallIdentifier& callIdentifier)
{
if (m_callIdentifier == callIdentifier) {
m_visible = true;
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
(*currentChild)->setTreeVisible(true);
} else {
m_visible = false;
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
m_visible = (*currentChild)->focus(callIdentifier) || m_visible;
}
return m_visible;
}
void ProfileNode::restoreAll()
{
m_visible = true;
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
(*currentChild)->restoreAll();
}
void ProfileNode::endAndRecordCall()
{
m_totalTime += getCurrentUTCTimeWithMicroseconds() - m_startTime;
......@@ -256,7 +289,7 @@ void ProfileNode::debugPrintData(int indentLevel) const
for (int i = 0; i < indentLevel; ++i)
printf(" ");
printf("%d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% Full Name %s\n", m_numberOfCalls, m_selfTime, selfPercent(), m_totalTime, totalPercent(), functionName().UTF8String().c_str());
printf("%d SelfTime %.3fms/%.3f%% TotalTime %.3fms/%.3f%% Full Name %s Visible %s\n", m_numberOfCalls, m_selfTime, selfPercent(), m_totalTime, totalPercent(), functionName().UTF8String().c_str(), (m_visible ? "True" : "False"));
++indentLevel;
......
......@@ -79,6 +79,9 @@ namespace KJS {
unsigned numberOfCalls() const { return m_numberOfCalls; }
void setNumberOfCalls(unsigned number) { m_numberOfCalls = number; }
const Vector<RefPtr<ProfileNode> >& children() { return m_children; }
bool visible() const { return m_visible; }
void setVisible(bool visible) { m_visible = visible; }
void setTreeVisible(bool visible);
// Sorting functions
void sortTotalTimeDescending();
......@@ -90,9 +93,12 @@ namespace KJS {
void sortFunctionNameDescending();
void sortFunctionNameAscending();
void endAndRecordCall();
bool focus(const CallIdentifier& callIdentifier);
void restoreAll();
void endAndRecordCall();
void calculatePercentages(double totalProfileTime);
#ifndef NDEBUG
void debugPrintData(int indentLevel) const;
double debugPrintDataSampleStyle(int indentLevel, FunctionCallHashCount&) const;
......@@ -108,6 +114,8 @@ namespace KJS {
double m_totalPercent;
double m_selfPercent;
unsigned m_numberOfCalls;
bool m_visible;
Vector<RefPtr<ProfileNode> > m_children;
};
......
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