1 |
/* |
2 |
* Time module |
3 |
* by Karl Westerberg |
4 |
* Created: 6/90 |
5 |
* Version: $Revision: 1.1 $ |
6 |
* Version control file: $RCSfile: tm_time.h,v $ |
7 |
* Date last modified: $Date: 2000/01/25 02:21:26 $ |
8 |
* Last modified by: $Author: ballan $ |
9 |
* |
10 |
* This file is part of the Ascend Language Interpreter. |
11 |
* |
12 |
* Copyright (C) 1997 Carnegie Mellon University |
13 |
* |
14 |
* The Ascend Language Interpreter is free software; you can redistribute |
15 |
* it and/or modify it under the terms of the GNU General Public License as |
16 |
* published by the Free Software Foundation; either version 2 of the |
17 |
* License, or (at your option) any later version. |
18 |
* |
19 |
* The Ascend Language Interpreter is distributed in hope that it will be |
20 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 |
* General Public License for more details. |
23 |
* |
24 |
* You should have received a copy of the GNU General Public License |
25 |
* along with the program; if not, write to the Free Software Foundation, |
26 |
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
27 |
* COPYING. COPYING is in ../compiler. |
28 |
*/ |
29 |
|
30 |
/** @file |
31 |
* <pre> |
32 |
* Contents: Time module |
33 |
* |
34 |
* Authors: Karl Westerberg |
35 |
* Joseph Zaher |
36 |
* |
37 |
* Dates: 06/90 - original version |
38 |
* 08/93 - removed CLOCKS_PER_SECOND which should be |
39 |
* provided by the standard library, eliminated |
40 |
* tm_TPS and changed tm_run_time() and |
41 |
* tm_cpu_time() to return number of seconds |
42 |
* 06/94 - eliminated cute calendar functions for full |
43 |
* ANSI compatibility. |
44 |
* |
45 |
* Description: Provide a function to monitor elapsed time during the |
46 |
* course of execution of a program and standard ANSI |
47 |
* primitives for performing calendar calculations. |
48 |
* |
49 |
* Apology: We apologize for the existence of this file and for |
50 |
* its name being the same as an ANSI C header which is not |
51 |
* consistently available, unfortunately. We really |
52 |
* ought not to need this header. |
53 |
* |
54 |
* Requires: #include "utilities/ascConfig.h" |
55 |
* </pre> |
56 |
*/ |
57 |
|
58 |
#ifndef ASC_TM_TIME_H |
59 |
#define ASC_TM_TIME_H |
60 |
|
61 |
#ifndef CLOCKS_PER_SEC |
62 |
|
63 |
/* case linux */ |
64 |
#ifdef linux |
65 |
#define CLOCKS_PER_SEC 100 /**< Typical clock ticks per sec. */ |
66 |
#endif /* linux */ |
67 |
|
68 |
/* case windoze */ |
69 |
#ifdef __WIN32__ |
70 |
#define CLOCKS_PER_SEC 1000 /**< Typical clock ticks per sec. */ |
71 |
#endif /* windoze */ |
72 |
|
73 |
/* default */ |
74 |
#ifndef CLOCKS_PER_SEC |
75 |
#define CLOCKS_PER_SEC 1000000 |
76 |
/**< |
77 |
* Typical clock ticks per sec. Note that typically clocks |
78 |
* have a minimum resolution of 16666, sigh. |
79 |
*/ |
80 |
#endif /* default */ |
81 |
|
82 |
#endif /* CLOCKS_PER_SEC */ |
83 |
|
84 |
extern double tm_cpu_time(void); |
85 |
/**< |
86 |
* Returns elapsed CPU time in seconds since the first call |
87 |
* to a timing function. The timing functions that, when |
88 |
* initially called, set the start time for all others are: |
89 |
* - tm_cpu_time() |
90 |
* - tm_cpu_time_ftn_() |
91 |
* - aftime_() |
92 |
* - tm_cpu_time_ftn() |
93 |
* - aftime() |
94 |
* - TM_CPU_TIME_FTN() |
95 |
* - AFTIME() |
96 |
* |
97 |
* Users timing portions of the process should maintain their |
98 |
* own start time and work by difference as the solvers do. |
99 |
* |
100 |
* @return The elapsed CPU time since the 1st call to a timing function. |
101 |
*/ |
102 |
|
103 |
extern double tm_reset_cpu_time(void); |
104 |
/**< |
105 |
* Resets the start time. Use with caution if there are |
106 |
* multiple callers depending on a constant start time stamp. |
107 |
* This function is primarily for testing purposes. |
108 |
* |
109 |
* @return The initiallized elapsed CPU time. |
110 |
*/ |
111 |
|
112 |
extern void tm_cpu_time_ftn_(double *time); |
113 |
/**< |
114 |
* Stores elapsed CPU time in seconds since the first call |
115 |
* to a timing function in *t*. The timing functions that, when |
116 |
* initially called, set the start time for all others are: |
117 |
* - tm_cpu_time() |
118 |
* - tm_cpu_time_ftn_() |
119 |
* - aftime_() |
120 |
* - tm_cpu_time_ftn() |
121 |
* - aftime() |
122 |
* - TM_CPU_TIME_FTN() |
123 |
* - AFTIME() |
124 |
* |
125 |
* This function takes a (double *) to satisfy FORTRAN's call |
126 |
* by reference semantics. |
127 |
* <pre> |
128 |
* f77 usage: t is real*8 (double precision on most f77) |
129 |
* external aftime, tm_cpu_time_ftn |
130 |
* call tm_cpu_time_ftn(t) |
131 |
* call aftime(t) |
132 |
* </pre> |
133 |
* On return t will have a time value (sec) stored in a double. |
134 |
* The specified t may not be NULL (checked by assertion).<br><br> |
135 |
* |
136 |
* If your F77 compiler doesn't morph all function calls to |
137 |
* lower case (with or without trailing underbar), you will need |
138 |
* to figure out its morphing convention and modify tm.[ch] so. |
139 |
* |
140 |
* @param t Location to store the elapsed CPU time in seconds. |
141 |
*/ |
142 |
|
143 |
extern void aftime_(double *time); |
144 |
/**< Short name for tm_cpu_time_ftn_() to satisfy FORTRAN's 6 char restriction. */ |
145 |
extern void tm_cpu_time_ftn(double *time); |
146 |
/**< Variant of tm_cpu_time_ftn_(). */ |
147 |
extern void aftime(double *time); |
148 |
/**< Short name for tm_cpu_time_ftn() to satisfy FORTRAN's 6 char restriction. */ |
149 |
extern void TM_CPU_TIME_FTN(double *time); |
150 |
/**< Variant of tm_cpu_time_ftn_(). */ |
151 |
extern void AFTIME(double *time); |
152 |
/**< Short name for TM_CPU_TIME_FTN() to satisfy FORTRAN's 6 char restriction. */ |
153 |
|
154 |
#endif /* ASC_TM_TIME_H */ |
155 |
|