LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can I somehow accurately measure the time a operation takes? Like 'unzip -x foo.zip'? (https://www.linuxquestions.org/questions/linux-newbie-8/can-i-somehow-accurately-measure-the-time-a-operation-takes-like-unzip-x-foo-zip-219381/)

brynjarh 08-18-2004 03:42 PM

Can I somehow accurately measure the time an operation like 'unzip -x foo.zip' takes?
 
Is it possible to somehow measure the time accurately from when an operation starts to when it ends?
So I can measure how long it takes for me to unzip a file for example?

ranger_nemo 08-18-2004 03:52 PM

Start the command with "time "...

time unzip -x foo.zip

brynjarh 08-18-2004 04:04 PM

Thanks, I tried it out and this is what I got:
Code:

HAL:/home/brynjarh# time unzip -x foo_zip.zip
Archive:  foo_zip.zip
  inflating: screenshot.bmp

real    0m0.094s
user    0m0.010s
sys    0m0.000s

I'm a little confused by the difference on real <time> and user <time>, what's the difference?

Tinkster 08-18-2004 04:08 PM

man time



Cheers,
Tink

bröggle 08-18-2004 08:49 PM

thanks for the time tip, but
man time shows me only something about the system call time in order to get a unix timestamp (right spelling?)
and something about posix standard etc, but nothing about the time "tool".


neither about any options from time (time --help)

So what? Online-Man? Is time some kind of alias?

(if anybody wants it, I could paste the german man page of it ;-)

Tinkster 08-18-2004 08:59 PM

Try
man 1 time
then ...



Strange that it should default to man 2 in this case.



Code:

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)).


Cheers,
Tink

CSIXTY4 08-18-2004 09:02 PM

The "manual" is divided into the following sections:

1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]

The "time" command would be found in section 1, and you can read that man page by typing:

Code:

man 1 time
Hope that helps!

bröggle 08-18-2004 09:18 PM

I tried but heres the german output of it :
Keine Handbuch-Seite time in der Sektion 1

or in english,please:
there is no time man page in section one.




:cry:

ranger_nemo 08-18-2004 09:24 PM

Code:

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.

EXITSTATUS
      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.

SEEALSO
      times(2),



GNUVERSION
      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.

  Theformatstring
      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.

GNUOPTIONS
      -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.

GNUSTANDARDOPTIONS
      --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-utilsprep.edu
      Please  include the version of time, which you can get by
      running
      time --version
      and the operating system and C compiler you used.

SEEALSO
      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)


bröggle 08-18-2004 09:26 PM

Thank you very much.


All times are GMT -5. The time now is 11:52 AM.