From 6101f799d390459469e13f0310410608686d4df8 Mon Sep 17 00:00:00 2001 From: "kmccullough@apple.com" Date: Wed, 14 May 2008 23:02:57 +0000 Subject: [PATCH] JavaScriptCore: 2008-05-14 Kevin McCullough Reviewed by John. JavaScript profiler (10928) - Have each FunctionCallProfile be able to return it's total and self time. * JavaScriptCore.exp: * profiler/FunctionCallProfile.cpp: (KJS::FunctionCallProfile::selfTime): * profiler/FunctionCallProfile.h: (KJS::FunctionCallProfile::totalTime): WebCore: 2008-05-14 Kevin McCullough Reviewed by John. - JavaScript profiler (10928) Use the FunctionCallProfile's new total and self time functions. * page/JavaScriptFunctionCallProfile.cpp: (WebCore::getTotalTime): (WebCore::getSelfTime): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33464 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- JavaScriptCore/ChangeLog | 13 +++++++++++++ JavaScriptCore/JavaScriptCore.exp | 1 + JavaScriptCore/profiler/FunctionCallProfile.cpp | 12 ++++++++++++ JavaScriptCore/profiler/FunctionCallProfile.h | 3 ++- WebCore/ChangeLog | 11 +++++++++++ WebCore/page/JavaScriptFunctionCallProfile.cpp | 4 ++-- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index ba22b923d3f..43321d8dddc 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,16 @@ +2008-05-14 Kevin McCullough + + Reviewed by John. + + JavaScript profiler (10928) + - Have each FunctionCallProfile be able to return it's total and self time. + + * JavaScriptCore.exp: + * profiler/FunctionCallProfile.cpp: + (KJS::FunctionCallProfile::selfTime): + * profiler/FunctionCallProfile.h: + (KJS::FunctionCallProfile::totalTime): + 2008-05-14 Alexey Proskuryakov Reviewed by Darin. diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp index 603757462b3..711ef44fd24 100644 --- a/JavaScriptCore/JavaScriptCore.exp +++ b/JavaScriptCore/JavaScriptCore.exp @@ -240,6 +240,7 @@ __ZNK3KJS14JSGlobalObject14isDynamicScopeEv __ZNK3KJS14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE __ZNK3KJS16JSVariableObject16isVariableObjectEv __ZNK3KJS16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj +__ZNK3KJS19FunctionCallProfile8selfTimeEv __ZNK3KJS19InternalFunctionImp14implementsCallEv __ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv __ZNK3KJS4List8getSliceEiRS0_ diff --git a/JavaScriptCore/profiler/FunctionCallProfile.cpp b/JavaScriptCore/profiler/FunctionCallProfile.cpp index f8510a2d1bd..f1cce1ffd95 100644 --- a/JavaScriptCore/profiler/FunctionCallProfile.cpp +++ b/JavaScriptCore/profiler/FunctionCallProfile.cpp @@ -98,6 +98,18 @@ void FunctionCallProfile::stopProfiling() (*it)->stopProfiling(); } +double FunctionCallProfile::selfTime() const +{ + double sumChildrenTime = 0.0; + + for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild) + sumChildrenTime += (*currentChild)->totalTime(); + + ASSERT(sumChildrenTime <= m_timeSum); + + return m_timeSum - sumChildrenTime; +} + void FunctionCallProfile::printDataInspectorStyle(int indentLevel) const { // Print function names diff --git a/JavaScriptCore/profiler/FunctionCallProfile.h b/JavaScriptCore/profiler/FunctionCallProfile.h index 43cf44a1db9..90f523890cf 100644 --- a/JavaScriptCore/profiler/FunctionCallProfile.h +++ b/JavaScriptCore/profiler/FunctionCallProfile.h @@ -55,7 +55,8 @@ namespace KJS { void stopProfiling(); UString functionName() const { return m_functionName; } - double milliSecs() const { return m_timeSum; } + double totalTime() const { return m_timeSum; } + double selfTime() const; unsigned numberOfCalls() const { return m_numberOfCalls; } const Deque >& children() { return m_children; } diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index f29ed308466..55ee150cb31 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,14 @@ +2008-05-14 Kevin McCullough + + Reviewed by John. + + - JavaScript profiler (10928) + Use the FunctionCallProfile's new total and self time functions. + + * page/JavaScriptFunctionCallProfile.cpp: + (WebCore::getTotalTime): + (WebCore::getSelfTime): + 2008-05-14 Anders Carlsson Reviewed by Adam. diff --git a/WebCore/page/JavaScriptFunctionCallProfile.cpp b/WebCore/page/JavaScriptFunctionCallProfile.cpp index 7c1af354a97..015d763bf80 100644 --- a/WebCore/page/JavaScriptFunctionCallProfile.cpp +++ b/WebCore/page/JavaScriptFunctionCallProfile.cpp @@ -70,7 +70,7 @@ static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStrin return JSValueMakeUndefined(ctx); FunctionCallProfile* functionCallProfile = static_cast(JSObjectGetPrivate(thisObject)); - return JSValueMakeNumber(ctx, functionCallProfile->milliSecs()); + return JSValueMakeNumber(ctx, functionCallProfile->totalTime()); } static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) @@ -81,7 +81,7 @@ static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSString return JSValueMakeUndefined(ctx); FunctionCallProfile* functionCallProfile = static_cast(JSObjectGetPrivate(thisObject)); - return JSValueMakeNumber(ctx, functionCallProfile->milliSecs()); + return JSValueMakeNumber(ctx, functionCallProfile->selfTime()); } static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) -- GitLab