I had a few questions on how I'm measuring startup, so here's how. This is similar to what our tinderboxes do, and it's easy to run locally.
First, grab startup.html and save it somewhere. This html file expects the start time in milliseconds to come after a # mark, so to invoke it, you'd want to do something like (assuming a profile called "ts", that optionally has browser.dom.window.dump set to true):
./firefox -P ts -no-remote file:///..../startup.html#1248839367203
Unfortunately the standard 'date' tool doesn't help with generating the millisecond timestamp, nor does it exist on Windows. But, this python one-liner works:
python -c 'import time; print int(time.time() * 1000);'
So, combine the two together:
./firefox -P ts -no-remote file:///..../startup.html#`python -c 'import time; print int(time.time() * 1000);'`
And you're done. You'll see a number like "ELAPSED 800" show up in the window and in the console. You might notice that this script also dumps "KILL" to the console as well... this isn't me working out some aggression, instead it's a hack that I made locally to dom/base/nsGlobalWindow.cpp's nsGlobalWindow::Dump — if it sees "KILL" as the start of a dump line, it'll immediately call abort(). Handy when profiling startup. Originally this was "KILL THEM", but that seemed just a little too aggro for this blog post.
Also, the python overhead is negligible (1-2ms and constant), but if that's too much for you, it's not too hard to write a command line program to call gettimeofday() and print the msec time.
These startup posts are great, but you really buried the lede with that Armstrong and Miller video.
I saw that python one liner and my first thought was:
perl -e ‘print time’
But I’ve spent way too much time writing perl.
I was thrilled when I found clock_gettime in libc, it’s perfect for benchmarking (on linux anyway). You have both CLOCK_REALTIME and CLOCK_PROCESS_CPUTIME_ID for example.
You can use unix date also. It might be a little faster than loading all of python just to spit out unix epoch seconds.
date %s.%N
Yeah, could’ve used perl as well; python is a standard part of our build system install though, and so is generally more available. The startup time of python is irrelevant; only the time from print until the process exits. Doing “python … ; datemsec” (where datemsec was my standalone C program), the number from datemsec was generally only 1-2 msec more.
I would’ve liked to use date, but %N is a nonstandard GNU extension.