Sierra Toolkit  Version of the Day
WallTime.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #include <stk_util/environment/WallTime.hpp>
10 
11 #include <sys/time.h>
12 
13 namespace stk_classic {
14 
15 double
17 {
18  timeval tp;
19  struct timezone tz;
20  ::gettimeofday(&tp, &tz);
21 
22  double seconds = tp.tv_sec;
23  double milliseconds = tp.tv_usec*1.0e-6;
24 
25  return seconds + milliseconds;
26 }
27 
28 
29 double
30 wall_dtime(double &t)
31 {
32  const double tnew = wall_time();
33 
34  const double dt = tnew - t;
35 
36  t = tnew ;
37 
38  return dt ;
39 }
40 
41 } // namespace stk_classic
double wall_time()
Member function wall_time returns the epoch as a double precision value in seconds to "millisecond" a...
Definition: WallTime.cpp:16
Sierra Toolkit.