TIME(1)                    POSIX Programmer's Manual                   TIME(1)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       time -- time a simple command

SSYYNNOOPPSSIISS
       time [[-p]] _u_t_i_l_i_t_y [[_a_r_g_u_m_e_n_t...]]

DDEESSCCRRIIPPTTIIOONN
       The _t_i_m_e utility shall invoke the utility named by the _u_t_i_l_i_t_y operand
       with arguments supplied as the _a_r_g_u_m_e_n_t operands and write a message to
       standard error that lists timing statistics for the utility. The
       message shall include the following information:

        *  The elapsed (real) time between invocation of _u_t_i_l_i_t_y and its
           termination.

        *  The User CPU time, equivalent to the sum of the _t_m_s___u_t_i_m_e and
           _t_m_s___c_u_t_i_m_e fields returned by the _t_i_m_e_s() function defined in the
           System Interfaces volume of POSIX.1-2008 for the process in which
           _u_t_i_l_i_t_y is executed.

        *  The System CPU time, equivalent to the sum of the _t_m_s___s_t_i_m_e and
           _t_m_s___c_s_t_i_m_e fields returned by the _t_i_m_e_s() function for the process
           in which _u_t_i_l_i_t_y is executed.

       The precision of the timing shall be no less than the granularity
       defined for the size of the clock tick unit on the system, but the
       results shall be reported in terms of standard time units (for example,
       0.02 seconds, 00:00:00.02, 1m33.75s, 365.21 seconds), not numbers of
       clock ticks.

       When _t_i_m_e is used as part of a pipeline, the times reported are
       unspecified, except when it is the sole command within a grouping
       command (see _S_e_c_t_i_o_n _2_._9_._4_._1, _G_r_o_u_p_i_n_g _C_o_m_m_a_n_d_s) in that pipeline. For
       example, the commands on the left are unspecified; those on the right
       report on utilities aa and cc, respectively:

           ttiimmee aa || bb || cc    {{ ttiimmee aa;; }} || bb || cc
           aa || bb || ttiimmee cc    aa || bb || ((ttiimmee cc))

OOPPTTIIOONNSS
       The _t_i_m_e utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following option shall be supported:

       --pp        Write the timing output to standard error in the format shown
                 in the STDERR section.

OOPPEERRAANNDDSS
       The following operands shall be supported:

       _u_t_i_l_i_t_y   The name of a utility that is to be invoked. If the _u_t_i_l_i_t_y
                 operand names any of the special built-in utilities in
                 _S_e_c_t_i_o_n _2_._1_4, _S_p_e_c_i_a_l _B_u_i_l_t_-_I_n _U_t_i_l_i_t_i_e_s, the results are
                 undefined.

       _a_r_g_u_m_e_n_t  Any string to be supplied as an argument when invoking the
                 utility named by the _u_t_i_l_i_t_y operand.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       None.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _t_i_m_e:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2008, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  Determine the locale for the interpretation of sequences of
                 bytes of text data as characters (for example, single-byte as
                 opposed to multi-byte characters in arguments).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic and informative messages written
                 to standard error.

       _L_C___N_U_M_E_R_I_C
                 Determine the locale for numeric formatting.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

       _P_A_T_H      Determine the search path that shall be used to locate the
                 utility to be invoked; see the Base Definitions volume of
                 POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t _V_a_r_i_a_b_l_e_s.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       Not used.

SSTTDDEERRRR
       The standard error shall be used to write the timing statistics. If --pp
       is specified, the following format shall be used in the POSIX locale:

           ""rreeaall %%ff\\nnuusseerr %%ff\\nnssyyss %%ff\\nn"",, <<_r_e_a_l _s_e_c_o_n_d_s>, <_u_s_e_r _s_e_c_o_n_d_s>,
               <_s_y_s_t_e_m _s_e_c_o_n_d_s>

       where each floating-point number shall be expressed in seconds. The
       precision used may be less than the default six digits of %%ff, but shall
       be sufficiently precise to accommodate the size of the clock tick on
       the system (for example, if there were 60 clock ticks per second, at
       least two digits shall follow the radix character). The number of
       digits following the radix character shall be no less than one, even if
       this always results in a trailing zero. The implementation may append
       white space and additional information following the format shown here.
       The implementation may also prepend a single empty line before the
       format shown here.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       If the _u_t_i_l_i_t_y utility is invoked, the exit status of _t_i_m_e shall be the
       exit status of _u_t_i_l_i_t_y; otherwise, the _t_i_m_e utility shall exit with one
       of the following values:

       1-125   An error occurred in the _t_i_m_e utility.

         126   The utility specified by _u_t_i_l_i_t_y was found but could not be
               invoked.

         127   The utility specified by _u_t_i_l_i_t_y could not be found.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The _c_o_m_m_a_n_d, _e_n_v, _n_i_c_e, _n_o_h_u_p, _t_i_m_e, and _x_a_r_g_s utilities have been
       specified to use exit code 127 if an error occurs so that applications
       can distinguish ``failure to find a utility'' from ``invoked utility
       exited with an error indication''. The value 127 was chosen because it
       is not commonly used for other meanings; most utilities use small
       values for ``normal error conditions'' and the values above 128 can be
       confused with termination due to receipt of a signal. The value 126 was
       chosen in a similar manner to indicate that the utility could be found,
       but not invoked. Some scripts produce meaningful error messages
       differentiating the 126 and 127 cases. The distinction between exit
       codes 126 and 127 is based on KornShell practice that uses 127 when all
       attempts to _e_x_e_c the utility fail with [[EENNOOEENNTT]], and uses 126 when any
       attempt to _e_x_e_c the utility fails for any other reason.

EEXXAAMMPPLLEESS
       It is frequently desirable to apply _t_i_m_e to pipelines or lists of
       commands. This can be done by placing pipelines and command lists in a
       single file; this file can then be invoked as a utility, and the _t_i_m_e
       applies to everything in the file.

       Alternatively, the following command can be used to apply _t_i_m_e to a
       complex command:

           ttiimmee sshh --cc ''_c_o_m_p_l_e_x_-_c_o_m_m_a_n_d_-_l_i_n_e''

RRAATTIIOONNAALLEE
       When the _t_i_m_e utility was originally proposed to be included in the
       ISO POSIX-2:1993 standard, questions were raised about its suitability
       for inclusion on the grounds that it was not useful for conforming
       applications, specifically:

        *  The underlying CPU definitions from the System Interfaces volume of
           POSIX.1-2008 are vague, so the numeric output could not be compared
           accurately between systems or even between invocations.

        *  The creation of portable benchmark programs was outside the scope
           this volume of POSIX.1-2008.

       However, _t_i_m_e does fit in the scope of user portability. Human
       judgement can be applied to the analysis of the output, and it could be
       very useful in hands-on debugging of applications or in providing
       subjective measures of system performance. Hence it has been included
       in this volume of POSIX.1-2008.

       The default output format has been left unspecified because historical
       implementations differ greatly in their style of depicting this numeric
       output. The --pp option was invented to provide scripts with a common
       means of obtaining this information.

       In the KornShell, _t_i_m_e is a shell reserved word that can be used to
       time an entire pipeline, rather than just a simple command. The POSIX
       definition has been worded to allow this implementation. Consideration
       was given to invalidating this approach because of the historical model
       from the C shell and System V shell. However, since the System V _t_i_m_e
       utility historically has not produced accurate results in pipeline
       timing (because the constituent processes are not all owned by the same
       parent process, as allowed by POSIX), it did not seem worthwhile to
       break historical KornShell usage.

       The term _u_t_i_l_i_t_y is used, rather than _c_o_m_m_a_n_d, to highlight the fact
       that shell compound commands, pipelines, special built-ins, and so on,
       cannot be used directly.  However, _u_t_i_l_i_t_y includes user application
       programs and shell scripts, not just the standard utilities.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _C_h_a_p_t_e_r _2, _S_h_e_l_l _C_o_m_m_a_n_d _L_a_n_g_u_a_g_e, _s_h

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

       The System Interfaces volume of POSIX.1-2008, _t_i_m_e_s()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                              TIME(1)
