Menu

FAQ Log in to Edit

Heiner

Frequently Asked Questions

1. Why are timing values sometimes printed with 2 decimal places, sometimes with more (e.g. 6 places)?

runtimes internally knows two different ways of measuring the run time of children processes:

  1. using the times(2) system call. The CLK_TCK macro gives the clock resolution in clock ticks per second. A frequent value is 100: 100 clock ticks per second = 10 milliseconds, the precision is 0.01 seconds. Try the command "getconf CLK_TCK" on the command line, it should print the clock resolution on your system.

  2. using the getrusage(2) system call for (user, sys CPU time) in combination with gettimeofday(2) for the "real" time. These system calls always return timing values with a resolution of microseconds (0.00001 second). Note that this is independant of the actual clock resolution of a system.

The precision part of the timing values, i.e. the number of decimal places after the integer part, depends on the clock resolution of the system. The "configure" script determins which of the two methods should be used for the current system.

2. How can I choose the method measuring children run times?

"configure" supports the two options
--with-times
and
--with-getrusage

for selecting one of the two methods. The precision itself cannot be changed directly using configure.

3. I'm a programmer and I still want to change the default precision on output

Programmers can change the following source code to modify the output of the program, the precision being part of it:

typedef struct {
    const char  *cd_heading;            /* Header string, e.g. "real" */
    int cd_width;                       /* Overall column width */
    int cd_intlen;                      /* Number: integer part length */
    int cd_precision;                   /* Number: fractional part length */
} coldef_t;

/*
 * These initial output column definition settings can be hard-coded
 * during compile time, or automatically determined during run time.
 * Positive values are hard-coded and will not change during run time,
 * negative values will be overwritten with runtime-determined values.
 */

static coldef_t coldef[] = {
    { "runs",    10,  0,  0 },
    { "real",   -10, -3, -6 },
    { "user",   -10, -3, -6 },
    { "sys",    -10, -3, -6 }
};

The third column specified the integer part, the forth column the decimal places of the number output. Set them to a fixed positive number to get numbers printed with a fixed number of integer/decimal places.

Of course this does not change the internal clock resolution, it just changes the way the internal numbers are printed.

4. Why does the program sometimes abort with an "invalid option" error?

Example:

    $ runtimes -n 3 ls -l
    runtimes: invalid option -- 'l'
    [...]

"runtimes" internally uses the getopt(3) function for parsing command line arguments. Some versions of it (e.g. the GNU version) do argument reordering.
In the example above the command "runtimes" got the arguments as follows:

    $ runtimes -n 3 -l ls

Since "-l" is not a valid option for "runtimes", the program aborts with an error message.

Avoid this problem by using the special option "--" . It strictly separates the options of "runtimes" from the options of the program to be run:

    $ runtimes -n 3 -- ls -l

Discussion

Anonymous
Anonymous

Add attachments
Cancel