Jean-Luc: perl benchmark

Hallo,

ich habe da ein kleines Verständnisproblem. Bei einem
Perl Skript (über Apache und Netscape) mit dem "timediff"
Aufruf erhalte ich folgendes Ergebnis:

The code took: 5 wallclock secs ( 2.37 usr + 0.00 sys = 2.37 CPU)

Sollte "wallclock" nicht in etwa die Summe von "usr" und "sys" sein ?

Was bedeutet nun "wallclock" und wo liegt der Unterschied
zwischen "usr" und "sys" ?

Leider habe ich hierzu nirgends eine Erklärung gefunden. Ich weiß ;-)
sicherlich gibt es die, aber wo ??? Perldoc und google haben jedenfalls
nicht geholfen ?

Vielen Dank
Gruß

Jean-Luc

  1. hi!

    The code took: 5 wallclock secs ( 2.37 usr + 0.00 sys = 2.37 CPU)
    Sollte "wallclock" nicht in etwa die Summe von "usr" und "sys" sein?

    Nicht unbedingt. Ich vermute eher, dass "wallclock" die gesamte reale
    Laufzeit des Programms ist. Wenn also nebenbei noch andere Prozesse
    laufen, erhalten die natürlich auch Laufzeit, die dann nicht bei der
    sys- und usr-Zeit des Prozesses mitgerechnet wird.

    Was bedeutet nun "wallclock" und wo liegt der Unterschied zwischen
    "usr" und "sys" ?

    Hm, "usr" ist die CPU-Zeit, die für die Ausführung der Instruktionen
    benötigt wird. "sys" ist dann vermutlich die Zeit, die der Prozess
    im supervisor-Mode verbringt, wenn er zb. Syscalls macht oder wenn
    er initialisiert wird. Dabei kann ich mich aber auch irren... ;)

    bye, Frank!

    1. Hallo,

      Hm, "usr" ist die CPU-Zeit, die für die Ausführung der
      Instruktionen benötigt wird. "sys" ist dann vermutlich die Zeit,
      die der Prozess im supervisor-Mode verbringt, wenn er zb.
      Syscalls macht oder wenn er initialisiert wird. Dabei kann ich
      mich aber auch irren... ;)

      Ich denke eher, 'usr' ist die User-Zeit und 'sys' ist die System-
      Zeit. User-Zeit heisst hierbei die reale Zeit, die der User warten
      muss. Daraus ergeben sich die 'Wallclocks', die wirklich reale Zeit,
      die der Prozess gelaufen ist. Dafuer wuerde der folgende Abschnitt
      aus `perldoc Benchmark' und die allgemeine Verwendung dieser
      Begriffe sprechen:

      NOTES
             The data is stored as a list of values from the time and
             times functions:

      ($real, $user, $system, $children_user, $children_system)

      in seconds for the whole loop (not divided by the number
             of rounds).

      Gruesse,
       CK

      1. Hallo,

        Hm, "usr" ist die CPU-Zeit, die für die Ausführung der Instruktionen benötigt wird. "sys" ist dann vermutlich die Zeit, die der Prozess im supervisor-Mode verbringt, wenn er zb. Syscalls macht oder wenn er initialisiert wird. Dabei kann ich mich aber auch irren... ;)

        Ich denke eher, 'usr' ist die User-Zeit und 'sys' ist die System- Zeit. User-Zeit heisst hierbei die reale Zeit, die der User warten muss. Daraus ergeben sich die 'Wallclocks', die wirklich reale Zeit, die der Prozess gelaufen ist. Dafuer wuerde der folgende Abschnitt aus `perldoc Benchmark' und die allgemeine Verwendung dieser Begriffe sprechen:

        NOTES        The data is stored as a list of values from the time and        times functions:

        ($real, $user, $system, $children_user, $children_system)

        in seconds for the whole loop (not divided by the number        of rounds).

        Gruesse, CK

        Neeneeneee!

        USR ist die Zeit, die ein Prozess im User-Mode, also außerhalb des Kernels, läuft. SYS ist die Zeit, die der Prozess im System-Mode läuft. Und Wallclock ist die Zeit zwischen Start und Ende des Prozesses, so wie ein Außenstehender (der Benutzer) die Zeit (mit der Uhr an der Wand) gemessen hätte.

        Das hat übrigens nix mit Perl zu tun, das sind einfach API-Funktionen der C-Library, die auf die Prozessdaten zugreifen.

        Wen's interessiert, hier die Man-Pages aus Linux.

        Alexander

        TIME(1)         TIME(1)

        NAME        time - time a simple command or give resource usage

        SYNOPSIS        time [options] command [arguments...]

        DESCRIPTION        The  time  command runs the specified program command with        the given arguments.  When command finishes, time writes a        message to standard output giving timing statistics about        this program run.  These statistics  consist  of  (i)  the        elapsed real time between invocation and termination, (ii)        the user CPU time (the sum of the tms_utime and tms_cutime        values in a struct tms as returned by times(2)), and (iii)        the  system  CPU  time  (the  sum  of  the  tms_stime  and        tms_cstime   values   in  a  struct  tms  as  returned  by        times(2)).

        OPTION        -p     When in the POSIX locale, use  the  precise  tradi-        tional format      "real %f\nuser %f\nsys %f\n"        (with numbers in seconds) where the number of deci-        mals in the output for %f  is  unspecified  but  is        sufficient  to express the clock tick accuracy, and        at least one.

        ENVIRONMENT        The  variables  LANG,   LC_ALL,  LC_CTYPE,   LC_MESSAGES,        LC_NUMERIC,  NLSPATH  and  PATH are used. The last one to        search for command.  The remaining ones for the text  and        formatting of the output.

        EXIT STATUS        If  command  was  invoked, the exit status is that of com-        mand.  Otherwise it is 127 if command could not be  found,        126  if it  could  be found but could not be invoked, and        some other nonzero value (1-125) if  something  else  went        wrong.

        SEE ALSO        times(2),

        GNU VERSION        Below  a description of the GNU 1.7 version of time.  Dis-        regarding the name of the utility,  GNU makes  it  output        lots  of useful information, not only about time used, but        also on other resources like memory,  I/O  and  IPC  calls        (where available).  The output is formatted using a format        string that can be specified using the -f  option  or  the        TIME environment variable.

        The default format string is    %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k    %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

        When the -p option is given the (portable) output format    real %e    user %U    sys %S        is used.

        The format string        The  format  is interpreted in the usual printf-like way.        Ordinary characters are directly copied, tab, newline  and        backslash  are escaped using \t, \n and \, a percent sign        is represented by %%, and otherwise % indicates a  conver-        sion.  The program time will always add a trailing newline        itself. The conversions follow.  All  of  those  used  by        tcsh(1) are supported.

        Time

        %E     Elapsed real time (in [hours:]minutes:seconds).

        %e     (Not in tcsh.) Elapsed real time (in seconds).

        %S     Total  number of CPU-seconds that the process spent        in kernel mode.

        %U     Total number of CPU-seconds that the process  spent        in user mode.

        %P     Percentage  of  the CPU that this job got, computed        as (%U + %S) / %E.

        Memory

        %M     Maximum resident set size of the process during its        lifetime, in Kbytes.

        %t     (Not  in tcsh.) Average  resident set size of the        process, in Kbytes.

        %K     Average total (data+stack+text) memory use  of  the        process, in Kbytes.

        %D     Average  size  of the process's unshared data area,        in Kbytes.

        %p     (Not  in tcsh.) Average  size  of  the process's        unshared stack space, in Kbytes.

        %X     Average size of the process's shared text space, in        Kbytes.

        %Z     (Not in tcsh.) System's page size, in bytes.   This        is  a  per-system constant, but varies between sys-        tems.

        %F     Number of major page faults that occurred while the        process  was  running.   These are faults where the        page has to be read in from disk.

        %R     Number  of  minor,  or  recoverable,  page  faults.        These  are  faults for pages that are not valid but        which have not yet been claimed  by  other  virtual        pages.   Thus  the  data in the page is still valid        but the system tables must be updated.

        %W     Number of times the process was swapped out of main        memory.

        %c     Number  of  times  the process was context-switched        involuntarily (because the time slice expired).

        %w     Number of waits: times that the  program was  con-        text-switched voluntarily, for instance while wait-        ing for an I/O operation to complete.

        I/O

        %I     Number of file system inputs by the process.

        %O     Number of file system outputs by the process.

        %r     Number of socket messages received by the  process.

        %s     Number of socket messages sent by the process.

        %k     Number of signals delivered to the process.

        %C     (Not  in tcsh.) Name and command line arguments of        the command being timed.

        %x     (Not in tcsh.) Exit status of the command.

        GNU OPTIONS        -f FORMAT, --format=FORMAT        Specify output format, possibly overriding the for-        mat specified in the environment variable TIME.

        -p, --portability        Use the portable output format.

        -o FILE, --output=FILE        Do  not  send  the results to stderr, but overwrite        the specified file.

        -a, --append        (Used together  with  -o.)  Do  not  overwrite  but        append.

        -v, --verbose        Give  very  verbose  output  about  all the program        knows about.

        GNU STANDARD OPTIONS        --help Print a usage message on standard output and  exit        successfully.

        -V, --version        Print  version information on standard output, then        exit successfully.

        --     Terminate option list.

        BUGS        Not all resources are measured by all versions of Unix, so        some of the values might be reported as zero.  The present        selection was mostly inspired by the data provided by  4.2        or 4.3BSD.

        GNU  time version 1.7 is not yet localized.  Thus, it does        not implement the POSIX requirements.

        The environment variable TIME was badly chosen. It is not        unusual for systems like autoconf or make to use environ-        ment variables with the name of a utility to override  the        utility to be used. Uses like MORE or TIME for options to        programs (instead of program path names) tend to  lead  to        difficulties.

        It   seems  unfortunate that  -o  overwrites  instead  of        appends.  (That is, the -a option should be the default.)

        Mail suggestions and bug reports for GNU time to        bug-utils@prep.ai.mit.edu        Please  include the version of time , which you can get by        running        time --version        and the operating system and C compiler you used.

        SEE ALSO        tcsh(1), times(2), wait3(2)

        AUTHORS        David Keppel        Original version

        David MacKenzie        POSIXization, autoconfiscation, GNU getopti-        zation,  documentation,  other bug fixes and        improvements.

        Arne Henrik Juul        Helped with portability

        Francois Pinard        Helped with portability

        2000-12-11     TIME(1) TIMES(2)     Linux Programmer's Manual   TIMES(2)

        NAME        times - get process times

        SYNOPSIS        #include <sys/times.h>

        clock_t times(struct tms *buf);

        DESCRIPTION        The  times()  function stores the current process times in        the struct tms that buf points to.  The struct tms  is  as        defined in <sys/times.h>:

        struct tms {        clock_t tms_utime;  /* user time /        clock_t tms_stime;  / system time /        clock_t tms_cutime; / user time of children /        clock_t tms_cstime; / system time of children */        };

        The  tms_utime field contains the CPU time spent executing        instructions of the calling process.  The tms_stime  field        contains  the CPU time spent in the system while executing        tasks on behalf of the calling  process.   The  tms_cutime        field  contains the  sum  of the tms_utime and tms_cutime        values  for  all  waited-for  terminated  children.    The        tms_cstime  field  contains  the  sum of the tms_stime and        tms_cstime values for all waited-for terminated children.

        Times  for  terminated children (and their descendants) is        added in at the moment wait(2) or waitpid(2) returns their        process ID. In particular, times of grandchildren that the        children did not wait for are never seen.

        All times reported are in clock ticks.

        RETURN VALUE        The function times returns the number of clock ticks  that        have  elapsed  since  an  arbitrary point in the past. For        Linux this point is the moment the  system  was  booted.        This  return value may overflow the possible range of type        clock_t.  On error, (clock_t) -1 is returned, and errno is        set appropriately.

        NOTE        The number of clock ticks per second can be obtained using        sysconf(_SC_CLK_TCK);        In POSIX-1996 the symbol CLK_TCK (defined in <time.h>)  is        mentioned as obsolescent. It is obsolete now.

        Note that clock(3) returns values of type clock_t that are        not measured in clock ticks but in CLOCKS_PER_SEC.

        CONFORMING TO        SVr4, SVID, POSIX, X/OPEN, BSD 4.3

        HISTORICAL NOTES        SVr1-3 returns long and the struct  members  are  of  type        time_t  although they store clock ticks, not seconds since        the epoch.  V7 used long for the struct members,  because        it had no type time_t yet.

        On  older  systems the number of clock ticks per second is        given by the variable HZ.

        SEE ALSO        time(1), getrusage(2), wait(2), clock(3), sysconf(3)

        Linux       2000-12-11    TIMES(2)