schulerlab has asked for the wisdom of the Perl Monks concerning the following question:

where can I find a definition of what exactly USER and SYSTEM means in terms of what is returned by the Benchmark program? Most of what I've found goes into detail about setting up benchmarks, but I can't find much on what exactly the numbers mean. Thanks

Replies are listed 'Best First'.
Re: benchmark: user vs system
by sgifford (Prior) on Aug 30, 2006 at 01:18 UTC
    User time is time your process spends in userspace, executing unprivileged code. System time is the amount of time the kernel spends on your belhalf.

    For example, if you multiply millions of numbers, you'll use tons of user time, but almost no system time. On the other hand, if you read many large files, you'll use a lot of system time but very little user time, since all I/O must go through the kernel.

    A third time is the "wallclock" time, which also includes the time your process spends waiting, either for access to the CPU, or else for a system call to complete.

    One way to get a feel for the difference is to run a system call tracer, like strace or truss. This will give you a log of every system call your process makes.

Re: benchmark: user vs system
by bigmacbear (Monk) on Aug 30, 2006 at 01:24 UTC

    On almost any system, performance is monitored by counting not only the elapsed time ("wallclock seconds") but also "CPU seconds", or in other words the amount of time your process spends actually running on the CPU as opposed to sleeping or waiting for some other process (such as I/O) to complete. On Unix and Unix-like systems, CPU time is further subdivided into at least two classes, "user" and "system" time.

    User time is time used by the CPU while running in your process's user space. This includes your code, as well as code such as the Perl interpreter itself or provided by a library/module.

    System time is time used by the CPU while running in the operating system space on behalf of your process.

    If you're on a Unix system, look at the man pages for time(1) and times(2) which are how Benchmark is probably implemented "under the hood". If you're on Windows, more than likely Perl is using either the Windows equivalent of the common Unix system calls above (any Windows based on the NT code base will have a POSIX subsystem that implements these system calls) or an emulation of them compiled into the Perl interpreter itself.

      Thank you so much for all the replies. I understand the difference between the two terms much better now. Thanks again.
Re: benchmark: user vs system
by grep (Monsignor) on Aug 30, 2006 at 01:19 UTC
    A simple explaination:
    (At least on *nix) "System time" is time taken by the processor on system tasks ( like I/O ) while performing instructions from your program. "User time" is the time taken by the processor for the general execution of the program (everything that is not "System Time").


    grep
    Mynd you, mønk bites Kan be pretti nasti...