/[ascend]/trunk/ascend/general/tm_time.c
ViewVC logotype

Annotation of /trunk/ascend/general/tm_time.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2011 - (hide annotations) (download) (as text)
Tue Apr 28 08:58:48 2009 UTC (15 years, 4 months ago) by jpye
File MIME type: text/x-csrc
File size: 2192 byte(s)
Moving libascend components from #/base/generic into #/ascend
1 aw0a 1 /*
2     * Time module
3     * by Karl Westerberg
4     * Created: 6/90
5     * Version: $Revision: 1.1 $
6     * Version control file: $RCSfile: tm_time.c,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     #include <time.h>
31 johnpye 399 #include <utilities/ascConfig.h>
32     #include <utilities/ascPanic.h>
33     #include "tm_time.h"
34 aw0a 1
35 jds 59 static boolean f_first = TRUE;
36    
37     double tm_cpu_time(void)
38 aw0a 1 {
39     static clock_t ref;
40     static double dref;
41     static double dcps;
42     clock_t now;
43     double dnow;
44    
45 jds 59 if( f_first ) {
46 aw0a 1 dcps = (double) CLOCKS_PER_SEC;
47     ref = clock();
48     dref = (double) ref;
49 jds 59 f_first = FALSE;
50 aw0a 1 }
51     now = clock();
52     dnow = (double) now;
53    
54     return( (dnow - dref)/dcps );
55     }
56    
57 jds 59 double tm_reset_cpu_time(void)
58     {
59     f_first = TRUE;
60     return tm_cpu_time();
61     }
62    
63 aw0a 1 void tm_cpu_time_ftn_(double *t)
64     {
65 jds 59 asc_assert(NULL != t);
66 aw0a 1 *t = tm_cpu_time();
67     }
68    
69     void aftime_(double *t)
70     {
71 jds 59 asc_assert(NULL != t);
72 aw0a 1 *t = tm_cpu_time();
73     }
74    
75     void tm_cpu_time_ftn(double *t)
76     {
77 jds 59 asc_assert(NULL != t);
78 aw0a 1 *t = tm_cpu_time();
79     }
80    
81     void aftime(double *t)
82     {
83 jds 59 asc_assert(NULL != t);
84 aw0a 1 *t = tm_cpu_time();
85     }
86    
87     void TM_CPU_TIME_FTN(double *t)
88     {
89 jds 59 asc_assert(NULL != t);
90 aw0a 1 *t = tm_cpu_time();
91     }
92    
93     void AFTIME(double *t)
94     {
95 jds 59 asc_assert(NULL != t);
96 aw0a 1 *t = tm_cpu_time();
97     }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22