source: icGREP/icgrep-devel/cudd-2.5.1/util/cpu_time.c @ 5820

Last change on this file since 5820 was 4597, checked in by nmedfort, 4 years ago

Upload of the CUDD library.

File size: 1.5 KB
Line 
1/* LINTLIBRARY */
2
3#include <stdio.h>
4#include "util.h"
5
6#ifdef IBM_WATC         /* IBM Waterloo-C compiler (same as bsd 4.2) */
7#define void int
8#define BSD
9#endif
10
11#ifdef BSD
12#include <sys/types.h>
13#include <sys/time.h>
14#include <sys/resource.h>
15#endif
16
17#if defined(UNIX60) || defined(UNIX100) || defined(__CYGWIN32__)
18#include <sys/types.h>
19#include <sys/times.h>
20#endif
21
22#ifdef vms              /* VAX/C compiler -- times() with 100 HZ clock */
23#include <types.h>
24#include <time.h>
25#endif
26
27
28
29/*
30 *   util_cpu_time -- return a long which represents the elapsed processor
31 *   time in milliseconds since some constant reference
32 */
33long 
34util_cpu_time()
35{
36    long t = 0;
37
38#ifdef BSD
39    struct rusage rusage;
40    (void) getrusage(RUSAGE_SELF, &rusage);
41    t = (long) rusage.ru_utime.tv_sec*1000 + rusage.ru_utime.tv_usec/1000;
42#endif
43
44#ifdef IBMPC
45    long ltime;
46    (void) time(&ltime);
47    t = ltime * 1000;
48#endif
49
50#ifdef UNIX60                   /* times() with 60 Hz resolution */
51    struct tms buffer;
52    times(&buffer);
53    t = buffer.tms_utime * 16.6667;
54#endif
55
56#ifdef UNIX100
57    struct tms buffer;          /* times() with 100 Hz resolution */
58    times(&buffer);
59    t = buffer.tms_utime * 10;
60#endif
61
62#ifdef __CYGWIN32__
63    /* Works under Windows NT but not Windows 95. */
64    struct tms buffer;          /* times() with 1000 Hz resolution */
65    times(&buffer);
66    t = buffer.tms_utime;
67#endif
68
69#ifdef vms
70    tbuffer_t buffer;   /* times() with 100 Hz resolution */
71    times(&buffer);
72    t = buffer.proc_user_time * 10;
73#endif
74
75    return t;
76}
Note: See TracBrowser for help on using the repository browser.