Monday, August 24, 2009

Webkit instrumentation in android

It is interesting to find webkit engine performance in terms of time taken by different tasks while loading the web page. Depending on the website page complexity it makes one curious to know how the page got loaded and what was the time consumption.

Android port of webkit has got one interesting instrumentation framework inplementation. In android source go to external/webkit directory and grep for ANDROID_INSTRUMENTATION...!! You will find in many places inside javascriptcore, Webcore, HTMLparsing, CSS parsing, layout and many other locations.

Android instrumentation framework is very well designed and impressive. I have been following this framework and this is improving in every release of webkit in android. Basically each component of webcore engine will register a timer with tag. This timer will be started when component start its job and records the time when completes. Refer timecounter.cpp/.h for more tags and counter options.
The output of the instrumentation will look like below which I tried on android emulator,
D/WebCore ( 700): *-* Start browser instrument
D/WebCore ( 700): *-* Total load time: 34832 ms, thread time: 23116 ms for file:///android_asset/ind.html
D/WebCore ( 700): *-* Total css parsing time: 250 ms called 6 times
D/WebCore ( 700): *-* Total javascript time: 13333 ms called 35 times
D/WebCore ( 700): *-* Total calculate style time: 279 ms called 9 times
D/WebCore ( 700): *-* Total Java callback (frame bridge) time: 510 ms called 79 times
D/WebCore ( 700): *-* Total parsing (may include calcStyle or Java callback) time: 2577 ms called 36 times
D/WebCore ( 700): *-* Total layout time: 1252 ms called 9 times
D/WebCore ( 700): *-* Total native 1 (frame bridge) time: 77 ms called 1 times
D/WebCore ( 700): *-* Total native 2 (resource load) time: 10804 ms called 206 times
D/WebCore ( 700): *-* Total native 3 (shared timer) time: 7676 ms called 22 times
D/WebCore ( 700): *-* Total build nav (webview core) time: 1264 ms called 3 times
D/WebCore ( 700): *-* Total record content (webview core) time: 1403 ms called 7 times
D/WebCore ( 700): *-* Total native 4 (webview core) time: 2043 ms called 27 times
D/WebCore ( 700): *-* Total draw content (webview ui) time: 961 ms called 10 times

4 comments:

Juan Uribe said...

I cannot find any trace of ANDROID_INSTRUMENTATION

From my android root directory
cd external/webkit
grep -R ANDROID_INSTRUMENTATION *

Juan Uribe said...

I forgot to point out that I have the latest version

Vinay H said...

Sorry it is ANDROID_INSTRUMENT...:-( I will correct it.
Please refer external/webkit/Android.mk file also.

Unknown said...

I uncommented WEBCORE_INSTRUMENTATION and saved the buildspec.mk.default file as buildspec.mk in "/mydroid".

After running make again, I started "/mydroid/out/host/linux-x86/bin/emulator" and "mydroid/out/host/linux-x86/bin/adb logcat".

In the emulator, I opened the browser and went to www.gmail.com, but no WebCore results like yours can be found in logcat. Also, "Home-Dev Tools-Instrumentation" in my emulator is blank.

Any suggestion is appreciated.