A simple task profiler for T-Kernel. (Modified to use less memory space compared to previous versions.)
`vfdrv' and `vfswitch' are driver and process-based application, respectively. Thus, you can compile each of these in $BD/driver/ and $BD/bappl/ directory, respectively.
lodspg vfdrv
, so that the profiler driver is loaded.$ vfswitch on 123
while in order to terminate profiler, type: $ vfswitch off
[/SYS]% fput vf.out 192.168.1.50:/home/takeshi/
[takeshi@YashiroRed pcat]$ vf.rb webkit.map vf.out [001] 660[ms] ( 86.8%) : sys=100%, usr= 0% : TShellGraphics::drawBitmap(TShellBitmap*, rect const&, rect const&) [002] 20[ms] ( 2.6%) : sys=100%, usr= 0% : TShellBufferedGraphics::~TShellBufferedGraphics() [003] 20[ms] ( 2.6%) : sys=100%, usr= 0% : WebCore::Font::drawGlyphs(WebCore::GraphicsContext*, WebCore::SimpleFontData const*, WebCore::GlyphBuffer const&, int, int, WebCore::FloatPoint const&) const [004] 20[ms] ( 2.6%) : sys= 0%, usr=100% : jscyyparse(void*) [005] 10[ms] ( 1.3%) : sys= 0%, usr=100% : BMLockTmo [006] 10[ms] ( 1.3%) : sys=100%, usr= 0% : TShellGraphics::fillRectangle(int, int, int, int) [007] 10[ms] ( 1.3%) : sys= 0%, usr=100% : WebCore::cssValueKeywordID(WebCore::CSSParserString const&) [008] 10[ms] ( 1.3%) : sys= 0%, usr=100% : _mem_malloc [009] 0[ms] ( 0.0%) : sys= 0%, usr= 0% : TShellApp::cycle() [010] 0[ms] ( 0.0%) : sys= 0%, usr= 0% : TShellWebKitPanel::onWorkAreaMouseDown()In the above example output, we can get that most of the time is spent on
TShellGraphics::drawBitmap
function, and that it is a good idea to select this function as the target you optimize. However, as system time is 100% for this period, this problem cannot be solved simply; instead, it is necessary to change the program structure to reduce the number of calls to time-consuming SVC functions. Mechanism is really simple: vfdrv checks and records PC (program counter) of the target tasks periodically (using cyclic handlers), and then vf.rb analyzes how much time is spent on each functions from these data. This mechanism is similar to sysprof in Linux, although they differ in that sysprof profiles the whole system, while vfdrv focuses on a specified task.
Unlike gprof, this profiler cannot show the number of calls to profiled functions, which cannot be achieved simply by this method. Instead, this profiler can profile kernel-based programs (by specifying tid from outer process), and does not modify any code or binaries.
[ Back ]
Yashiro Takeshi <yashiromann@gmail.com>