Back to index

cell-binutils  2.17cvs20070401
Defines | Functions
getruntime.c File Reference
#include "config.h"
#include "ansidecl.h"
#include "libiberty.h"
#include <sys/types.h>

Go to the source code of this file.

Defines

#define CLOCKS_PER_SEC   1
#define GNU_HZ   CLOCKS_PER_SEC

Functions

long get_run_time (void)

Define Documentation

#define CLOCKS_PER_SEC   1

Definition at line 65 of file getruntime.c.

#define GNU_HZ   CLOCKS_PER_SEC

Definition at line 75 of file getruntime.c.


Function Documentation

long get_run_time ( void  )

Definition at line 93 of file getruntime.c.

{
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
  struct rusage rusage;

  getrusage (0, &rusage);
  return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
         + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
#else /* ! HAVE_GETRUSAGE */
#ifdef HAVE_TIMES
  struct tms tms;

  times (&tms);
  return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
#else /* ! HAVE_TIMES */
  /* Fall back on clock and hope it's correctly implemented. */
  const long clocks_per_sec = CLOCKS_PER_SEC;
  if (clocks_per_sec <= 1000000)
    return clock () * (1000000 / clocks_per_sec);
  else
    return clock () / clocks_per_sec;
#endif  /* HAVE_TIMES */
#endif  /* HAVE_GETRUSAGE */
}

Here is the call graph for this function:

Here is the caller graph for this function: