Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/second.c
3196 views
1
/*****************************************************************************
2
*
3
* Elmer, A Finite Element Software for Multiphysical Problems
4
*
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program (in file fem/GPL-2); if not, write to the
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*
22
*****************************************************************************/
23
24
/*******************************************************************************
25
*
26
* Provide system time.
27
*
28
*******************************************************************************
29
*
30
* Author: Juha Ruokolainen
31
*
32
* Address: CSC - IT Center for Science Ltd.
33
* Keilaranta 14, P.O. BOX 405
34
* 02101 Espoo, Finland
35
* Tel. +358 0 457 2723
36
* Telefax: +358 0 457 2302
37
* EMail: [email protected]
38
*
39
* Date: 26 Sep 1995
40
*
41
* Modified by:
42
*
43
* Date of modification:
44
*
45
******************************************************************************/
46
47
48
#include "../config.h"
49
#ifndef WIN32
50
51
#include <sys/types.h>
52
#include <sys/times.h>
53
#include <sys/param.h>
54
55
#include <sys/time.h>
56
#include <sys/resource.h>
57
58
static struct tms t;
59
static struct rusage usage;
60
61
static struct timeval tp;
62
static struct timezone tzp;
63
64
double CPUTime( )
65
{
66
getrusage( RUSAGE_SELF, &usage );
67
return (double) usage.ru_utime.tv_sec + usage.ru_utime.tv_usec*1.0e-6;
68
}
69
70
double RealTime( )
71
{
72
gettimeofday( &tp,&tzp );
73
return tp.tv_sec + tp.tv_usec*1.0e-6;
74
}
75
76
#else
77
78
#include <sys/types.h>
79
#include <time.h>
80
81
double CPUTime() { return 0.0; }
82
83
double RealTime()
84
{
85
return clock() / (double)CLOCKS_PER_SEC;
86
}
87
88
#endif
89
90