Hello,
Yesterday I have been made aware of a built-in profiling tool in
MediaWiki. I played a bit with it and wondered if I could implement such
a tool for another project.
This afternoon I finally found a good way of profiling mediawiki cpu
usage, a picture of the result is at:
http://www.twenkill.net/phpprofiler.png
(might be unavailable depending of my home connection status).
Using debian GNU/Linux, following is a little howto to get the same
window opening on your screen.
1/ PROFILER
Install the profiling tool: apt-get install php4-apd
To enable profiling in mediawiki edit your index.php file and insert at
top: apd_set_pprof_trace();
Now each time a web request is made on your website, a file
pprof.<apachepid> will be generated in /var/log/php4-apd/
This is a serious performance eater and should only be enable when you
need profiling outputs !
2/ GUI FRONTEND
The gui frontend I use is Kcachegrind: apt-get install kcachegrind .
As far as I understand, it uses Caltree profiling tool and Valgrind to
make a graphical representation of a C software.
KCacheGrind isn't able to read pprof file format so you will have to
convert it. A script is available at:
http://cvs.php.net/co.php/pecl/apd/pprof2calltree?r=1.3
Eventually edit it so it looks like /usr/bin/pprof.
Then convert the pprof file:
$ pprof2calltree -f pprof.29539
Writing kcachegrind compatible output to cachegrind.out.pprof.29539
$ ls
cachegrind.out.pprof.29539 pprof.29539
$
If pprof2calltree start outputing lot of lines, you need to raise the
memory usage limit in your cgi php.ini file ( /etc/php4/cgi/php.ini ).
Now launch kcachegrind:
$ kcachegrind cachegrind.out.pprof.29539
Note:
You will need the graphwiz library to generate the call maps: apt-get
install graphwiz.
Enjoy ! :o)
--
Ashar Voultoiz
[[fr:Utilisateur:Hashar]]