Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
time.c File Reference
#include "plgetopt.h"
#include "nspr.h"
#include "prpriv.h"
#include "prinrval.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

Go to the source code of this file.

Defines

#define DEFAULT_COUNT   100000

Functions

void ftime_init ()
time_t ftime ()
static void timeTime (void)
static void timeGethrtime (void)
static void timeGettimeofday (void)
static void timePRTime32 (void)
static void timePRTime64 (void)
static void Measure (void(*func)(void), const char *msg)
void main (int argc, char **argv)
 The Xalan testcases app.

Variables

PRInt32 count
time_t itime
hrtime_t ihrtime

Define Documentation

#define DEFAULT_COUNT   100000

Definition at line 63 of file time.c.


Function Documentation

time_t ftime ( )

Definition at line 77 of file time.c.

{
        hrtime_t now = gethrtime();

        return itime + ((now - ihrtime) / 1000000000ll);
}

Here is the caller graph for this function:

Definition at line 70 of file time.c.

{
   itime = time(NULL);
   ihrtime = gethrtime();
}

Here is the caller graph for this function:

void main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 155 of file time.c.

{
       /* The command line argument: -d is used to determine if the test is being run
       in debug mode. The regress tool requires only one line output:PASS or FAIL.
       All of the printfs associated with this test has been handled with a if (debug_mode)
       test.
       Usage: test_name -d
       */
       PLOptStatus os;
       PLOptState *opt = PL_CreateOptState(argc, argv, "d:");
       while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
    {
              if (PL_OPT_BAD == os) continue;
        switch (opt->option)
        {
        case 'd':  /* debug mode */
                     debug_mode = 1;
            break;
         default:
            break;
        }
    }
       PL_DestroyOptState(opt);

    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    PR_STDIO_INIT();

    if (argc > 1) {
       count = atoi(argv[1]);
    } else {
       count = DEFAULT_COUNT;
    }

    ftime_init();

    Measure(timeTime, "time to get time with time()");
    Measure(timeGethrtime, "time to get time with gethrtime()");
    Measure(timeGettimeofday, "time to get time with gettimeofday()");
    Measure(timePRTime32, "time to get time with PR_Time() (32bit)");
    Measure(timePRTime64, "time to get time with PR_Time() (64bit)");

       PR_Cleanup();
       return 0;
}

Here is the call graph for this function:

static void Measure ( void(*)(void func,
const char *  msg 
) [static]

Definition at line 139 of file time.c.

{
    PRIntervalTime start, stop;
    double d;
    PRInt32 tot;

    start = PR_IntervalNow();
    (*func)();
    stop = PR_IntervalNow();

    d = (double)PR_IntervalToMicroseconds(stop - start);
    tot = PR_IntervalToMilliseconds(stop-start);

    if (debug_mode) printf("%40s: %6.2f usec avg, %d msec total\n", msg, d / count, tot);
}

Here is the caller graph for this function:

static void timeGethrtime ( void  ) [static]

Definition at line 93 of file time.c.

{
    PRInt32 index = count;
    time_t rv;
 
    for (;index--;)
        rv = ftime();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void timeGettimeofday ( void  ) [static]

Definition at line 102 of file time.c.

{
    PRInt32 index = count;
    time_t rv;
    struct timeval tp;
 
    for (;index--;)
        rv = gettimeofday(&tp, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void timePRTime32 ( void  ) [static]

Definition at line 112 of file time.c.

{
    PRInt32 index = count;
    PRInt32 rv32;
    PRTime q;
    PRTime rv;

    LL_I2L(q, 1000000);
 
    for (;index--;) {
        rv = PR_Now();
        LL_DIV(rv, rv, q);
        LL_L2I(rv32, rv);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void timePRTime64 ( void  ) [static]

Definition at line 128 of file time.c.

{
    PRInt32 index = count;
    PRTime rv;
 
    for (;index--;)
        rv = PR_Now();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void timeTime ( void  ) [static]

Definition at line 84 of file time.c.

{
    PRInt32 index = count;
    time_t rv;
 
    for (;index--;)
        rv = time(NULL);
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 64 of file time.c.

hrtime_t ihrtime

Definition at line 67 of file time.c.

time_t itime

Definition at line 66 of file time.c.