#include "util.h"
Go to the source code of this file.
Functions | |
long | util_cpu_time (void) |
long | util_cpu_ctime (void) |
long util_cpu_ctime | ( | void | ) |
Function********************************************************************
Synopsis [ Return elapsed time in milliseconds. It includes waited- for terminated children. ]
Description [ Return a long which represents the elapsed time in milliseconds since some constant reference. This time includes the CPU time spent executing instructions of the calling process and the time this process waited for its children to be terminated
There are two possibilities:
]
SideEffects [ none ]
Definition at line 147 of file cpu_time.c.
00148 { 00149 long t = 0; 00150 00151 #if HAVE_SYSCONF == 1 00152 00153 /* Code for POSIX systems */ 00154 00155 struct tms buffer; 00156 long nticks; /* number of clock ticks per second */ 00157 00158 nticks = sysconf(_SC_CLK_TCK); 00159 times(&buffer); 00160 t = (long) ((buffer.tms_utime + buffer.tms_cutime) * (1000.0/nticks)); 00161 00162 #else 00163 # ifndef vms 00164 00165 /* Code for non-POSIX systems */ 00166 00167 struct tms buffer; 00168 00169 time(&buffer); 00170 t = (buffer.tms_utime + buffer.tms_cutime) * 1000.0 / CLOCK_RESOLUTION; 00171 00172 # else 00173 00174 /* Code for VMS (?) */ 00175 00176 struct {int p1, p2, p3, p4;} buffer; 00177 static long ref_time; 00178 times(&buffer); 00179 t = (buffer.p1 + buffer.p3) * 10; 00180 if (ref_time == 0) 00181 ref_time = t; 00182 t = t - ref_time; 00183 00184 # endif /* vms */ 00185 #endif /* _POSIX_VERSION */ 00186 00187 return t; 00188 }
long util_cpu_time | ( | void | ) |
CFile***********************************************************************
FileName [ cpu_time.c ]
PackageName [ util ]
Synopsis [ System time calls ]
Description [ The problem is that all unix systems have a different notion of how fast time goes (i.e., the units returned by). This returns a consistent result. ]
Author [ Stephen Edwards <sedwards@eecs.berkeley.edu> and others ]
Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. All rights reserved.
Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]AutomaticStart AutomaticEnd Function********************************************************************
Synopsis [ Return elapsed time in milliseconds ]
Description [ Return a long which represents the elapsed time in milliseconds since some constant reference.
There are two possibilities:
]
SideEffects [ none ]
Definition at line 77 of file cpu_time.c.
00078 { 00079 long t = 0; 00080 00081 #if HAVE_SYSCONF == 1 00082 00083 /* Code for POSIX systems */ 00084 00085 struct tms buffer; 00086 long nticks; /* number of clock ticks per second */ 00087 00088 nticks = sysconf(_SC_CLK_TCK); 00089 times(&buffer); 00090 t = (long) (buffer.tms_utime * (1000.0/nticks)); 00091 00092 #else 00093 # ifndef vms 00094 00095 /* Code for non-POSIX systems */ 00096 00097 struct tms buffer; 00098 00099 time(&buffer); 00100 t = buffer.tms_utime * 1000.0 / CLOCK_RESOLUTION; 00101 00102 # else 00103 00104 /* Code for VMS (?) */ 00105 00106 struct {int p1, p2, p3, p4;} buffer; 00107 static long ref_time; 00108 times(&buffer); 00109 t = buffer.p1 * 10; 00110 if (ref_time == 0) 00111 ref_time = t; 00112 t = t - ref_time; 00113 00114 # endif /* vms */ 00115 #endif /* _POSIX_VERSION */ 00116 00117 return t; 00118 }