Webkit statistics of Android

来源:互联网 发布:人人会计软件 编辑:程序博客网 时间:2024/06/05 14:55

Introduction

1.Statistics Macro

 "ANDROID_INSTRUMENT"

2.Classes for statistics

a.TimeCounter
b.TimeCounterAuto

3. method for statistics
a. counting the time used for a single function.
b. counting the total time used by a kind of Timer.


TimerCounter
1.TimerCounter type.
One counter type stands for one type of operation.
    "css parsing", 
    "javascript",
    "javascript init",
    "javascript parsing",
    "javascript execution",
    "calculate style", 
    "Java callback (frame bridge)",
    "parsing (may include calcStyle, Java callback or inline script execution)",
    "layout", 
    "native 1 (frame bridge)",
    "native 2 (resource load)", 
    "native 3 (shared timer)", 
    "build nav (webview core)",
    "record content (webview core)",
    "native 4 (webview core)",
    "draw content (webview ui)",
    enum Type {
        // function base counters
        CSSParseTimeCounter,
        JavaScriptTimeCounter,
        JavaScriptInitTimeCounter,
        JavaScriptParseTimeCounter,
        JavaScriptExecuteTimeCounter,
        CalculateStyleTimeCounter,
        JavaCallbackTimeCounter,
        ParsingTimeCounter,
        LayoutTimeCounter,
        // file base counters
        NativeCallbackTimeCounter,  // WebCoreFrameBridge.cpp
        ResourceTimeCounter,        // WebCoreResourceLoader.cpp
        SharedTimerTimeCounter,     // JavaBridge.cpp
        WebViewCoreBuildNavTimeCounter,
        WebViewCoreRecordTimeCounter,
        WebViewCoreTimeCounter,     // WebViewCore.cpp
        WebViewUIDrawTimeCounter,
        TotalTimeCounterCount
    };

2.Array for holding the variables
uint32_t TimeCounter::sTotalTimeUsed[TimeCounter::TotalTimeCounterCount];
//the total time used for the kind of operation.
uint32_t TimeCounter::sLastTimeUsed[TimeCounter::TotalTimeCounterCount];
uint32_t TimeCounter::sCounter[TimeCounter::TotalTimeCounterCount];
//the total times of the kind of operation.
uint32_t TimeCounter::sLastCounter[TimeCounter::TotalTimeCounterCount];
uint32_t TimeCounter::sStartTime[TimeCounter::TotalTimeCounterCount];

3.function of the TimerCounter
a.void TimeCounter::start(enum Type type)
record the current time and store it in the "sStartTime" array.
b.void TimeCounter::record(enum Type type, const char* functionName)
calculate the elapsed time after start, and print it if the elapsed time is more than 1000ms
c.void TimeCounter::report(const KURL& url, int live, int dead, size_t arenaSize)
out put all the result of the statistics.
d.void TimeCounter::reportNow()
compare the current with the last.

4.usage
a.TimeCounter::start() at the start of the function
b.TimeCounter::record() at the end of the function.




TimeCounterAuto
1.variable
it has a membership "uint32_t m_startTime", as it was created, the current time is stored in the variable.
2.function 
a.TimeCounterAuto()
constructure function, store the current time in the "m_startTime".
b.~TimeCounterAuto()
get the elapsed time with the current time and "m_startTime" and record it the 
"sTotalTimeUsed" and "sCounter" as "TimeCounter" does.
3.usage
a.construct a local object of "TimeCounterAuto" at the beginning of the function.
b.the destructure function will be called automaticlly.



usage:

files that use "ANDROID_INSTRUMENT"

1. CSSParser 
parseSheet/parseRule/parseKeyframeRule/parseValue/parseColor/parseSelector/parseDeclaration/parseMediaQuery
//(start record)CSSParseTimeCounter
2. Document 
Document::recalcStyle //(start record)CalculateStyleTimeCounter
3. FrameLoader
FrameLoader::provisionalLoadStarted() //reset
FrameLoader::checkLoadCompleteForThisFrame()// report
4. FrameView
FrameView::layout() //  (start record) LayoutTimeCounter
5. HTMLDocumentParser
HTMLDocumentParser::insert// (start) ParsingTimeCounter
HTMLDocumentParser::append//(record) ParsingTimeCounter
6. JavaBridge
JavaBridge::SharedTimerFired //(start record)  SharedTimerTimeCounter
7. Parser
 Parser::parse // (start record)  JavaScriptParseTimeCounter
8.V8DOMWindowShell
V8DOMWindowShell::initContextIfNeeded//  (start record) JavaScriptInitTimeCounter
9.V8Proxy
V8Proxy::callFunction // (start record) JavaScriptExecuteTimeCounter
 V8Proxy::compileScript// record JavaScriptParseTimeCounter
V8Proxy::runScript // record JavaScriptExecuteTimeCounter
10.WebFrame
WebFrame ::startLoadingResource//( TimeCounterAuto ) JavaCallbackTimeCounter
WebFrame::shouldInterceptRequest//( TimeCounterAuto ) JavaCallbackTimeCounter
WebFrame::reportError
WebFrame::loadStarted
WebFrame::transitionToCommitted
WebFrame::didFinishLoad
WebFrame::removeHistoryItem
WebFrame::updateHistoryIndex
WebFrame::setTitle
WebFrame::windowObjectCleared
WebFrame::setProgress
WebFrame::didReceiveIcon
WebFrame::didReceiveTouchIconURL
WebFrame::updateVisitedHistory
WebFrame::canHandleRequest
WebFrame::createWindow
WebFrame::requestFocus
WebFrame::closeWindow
WebFrame::decidePolicyForFormResubmission
WebFrame::didReceiveAuthenticationChallenge
WebFrame::reportSslCertError
WebFrame::requestClientCert
WebFrame::downloadStart
WebFrame::didReceiveData
WebFrame::didFinishLoading
WebFrame::setCertificate
WebFrame::autoLogin

CallPolicyFunction
CreateFrame
DestroyFrame
LoadUrl
PostUrl
LoadData
StopLoading
ExternalRepresentation
DocumentAsText
ChildFramesAsText
Reload
GoBackOrForward
StringByEvaluatingJavaScriptFromString
AddJavascriptInterface
SetCacheDisabled
CacheDisabled
ClearCache
DocumentHasImages
HasPasswordField
GetUsernamePassword
SetUsernamePassword
OrientationChanged

11.WebCoreResourceLoader
WebCoreResourceLoader::SetResponseHeader//( TimeCounterAuto ) ResourceTimeCounter
WebCoreResourceLoader::CreateResponse
WebCoreResourceLoader::ReceivedResponse
WebCoreResourceLoader::AddData
WebCoreResourceLoader::Finished
WebCoreResourceLoader::RedirectedToUrl
WebCoreResourceLoader::Error

12.WebView.cpp
nativeInstrumentReport() //report now
13.WebViewCore
WebViewCore::recordPictureSet // ( TimeCounterAuto ) WebViewCoreRecordTimeCounter
WebViewCore::updateFrameCache// ( TimeCounterAuto ) WebViewCoreBuildNavTimeCounter
ClearContent//( TimeCounterAuto ) WebViewCoreTimeCounter
SetSize//( TimeCounterAuto ) WebViewCoreTimeCounter
SetScrollOffset//( TimeCounterAuto ) WebViewCoreTimeCounter
SetGlobalBounds//( TimeCounterAuto ) WebViewCoreTimeCounter
Key//( TimeCounterAuto ) WebViewCoreTimeCounter
Click//( TimeCounterAuto ) WebViewCoreTimeCounter
DeleteSelection//( TimeCounterAuto ) WebViewCoreTimeCounter
SetSelection
ModifySelection
ReplaceTextfieldText
PassToJs
ScrollFocusedTextInput
SetFocusControllerActive
SaveDocumentState
RecordContent
SplitContent
SendListBoxChoice
SendListBoxChoices
FindAddress
HandleTouchEvent
TouchUp
RetrieveHref
RetrieveAnchorText
MoveFocus
MoveMouse
MoveMouseIfLatest
UpdateFrameCache
GetContentMinPrefWidth
SetViewportSettingsFromNative
SetBackgroundColor
RegisterURLSchemeAsLocal//( TimeCounterAuto ) WebViewCoreTimeCounter


原创粉丝点击