HELPLIB.HLB  —  DECdts  utc_binreltime, Example
    The following example measures the duration of a process, then
    prints the resulting relative time and inaccuracy.

    utc_t               before, duration;
    reltimespec_t       tduration;
    timespec_t          iduration;

    /*
     *   Get the time before the start of the operation...
     */

    utc_gettime(&before);      /* Out: Before binary timestamp    */

    /*
     * ...Later...
     *
     * Subtract, getting the duration as a relative time.
     *
     *    NOTE: The NULL argument is used to obtain the current time.
     */

    utc_subtime(&duration,     /* Out: Duration rel bin timestamp  */
                (utc_t *)0,    /* In:  After binary timestamp      */
                &before);      /* In:  Before binary timestamp     */

    /*
     *    Convert the relative times to timespec structures...
     */

    utc_binreltime(&tduration, /* Out: Duration time timespec      */
                   &iduration, /* Out: Duration inacc timespec     */
                   &duration); /* In:  Duration rel bin timestamp  */

    /*
     *    Print the duration...
     */

    printf("%d.%04d", tduration.tv_sec, (tduration.tv_nsec/10000));

    if ((long)iduration.tv_sec == -1)
        printf("Iinf\n");
    else
    printf("I%d.%04d\n", iduration.tv_sec, (iduration.tv_nsec/100000));
Close Help