Measuring startup-time from userspace

January 02nd, 2011 - 06:10 pm ET by Taras Glek | Report spam
Hi,
Does Linux provide a reasonable way to measure how long a process has
existed for? The goal is to have a function that returns the number of
milliseconds since process-creation.

We'd like to be able to have Firefox self-diagnose startup times.
Unfortunately, it turns out that library loading time adds a lot to
startup before application code runs, so a in-application timer would
underestimate startup time.

It appears that the most precise solution is to read start time from
/proc/self/stat. Unfortunately the time is in jiffies-since-startup and
there don't seem to be any good counters to compare against (ie
/proc/uptime doesn't provide enough resolution). So far the only
workable solution seems to create a new thread/process. Then one can do
(/proc/<newpid>/stat.starttime - /proc/self/stat.starttime) * 1000 / HZ
.

The question is, there way for a process to measure time-since-startup
without horrible hacks like spawning a new processes?


Taras

ps. Perhaps /proc/timer_list contains enough info?
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
email Follow the discussionReplies 2 repliesReplies Make a reply

Replies

#1 Ben Gamari
January 02nd, 2011 - 08:40 pm ET | Report spam
On Sun, 02 Jan 2011 14:40:48 -0800, Taras Glek wrote:
The question is, there way for a process to measure time-since-startup
without horrible hacks like spawning a new processes?



Would you consider an LD_PRELOAD library to fall into the "hack"
category? I'm not sure when .init section is executed, but it might be
substantially earlier than when _start() is called.

- Ben
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Similar topics