From Fedora Project Wiki

Revision as of 20:01, 14 December 2009 by Valce (talk | contribs) (→‎Playing)

Description

Firefox comes with DTrace probe points that can be used to profile Javascript processes. Want to profile memory, time, etc. on your Javascript, using Fedora 12? This page will show you how.

Requirements

Setup

  • Download Firefox source from the above link.
  • Create a ~/.mozconfig and fill it as follows (Gently adapted from [| Uxebu])
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff
ac_add_options --enable-debug --disable-optimize
ac_add_options --enable-shared --disable-static --enable-dtrace
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
mk_add_options AUTOCONF="autoconf-2.13"
  • Install autoconf 2.13 (yum install autoconf213)
  • Enter the mozilla directory and run make -f client.mk build

Playing

The libmozjs can be found in (source directory)firefox/obj-ff/dist/lib/libmozjs.so, and the binary is located at (source directory)firefox/obj-ff/dist/bin/firefox. To see a list of all available markers, run stap -l 'process("/path/to/libmozjs.so").mark("*")

Example:

Using the following File:Javascript.stp basic script on the 'more complicated example' found [here], we get:

                File               |          Function          | Time(ms) | Called
 --------------------------------------------------------------------------------------
    ...me/valce/Desktop/draw.html  |                       dot  |        0 |     4
    ...me/valce/Desktop/draw.html  |                drawBowtie  |        1 |     4
    ...me/valce/Desktop/draw.html  |                    onload  |        7 |     1
    ...me/valce/Desktop/draw.html  |                      draw  |        6 |     1