|
Sierra Toolkit
Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 #include <stk_util/environment/WallTime.hpp> 00010 00011 #include <sys/time.h> 00012 00013 namespace stk_classic { 00014 00015 double 00016 wall_time() 00017 { 00018 timeval tp; 00019 struct timezone tz; 00020 ::gettimeofday(&tp, &tz); 00021 00022 double seconds = tp.tv_sec; 00023 double milliseconds = tp.tv_usec*1.0e-6; 00024 00025 return seconds + milliseconds; 00026 } 00027 00028 00029 double 00030 wall_dtime(double &t) 00031 { 00032 const double tnew = wall_time(); 00033 00034 const double dt = tnew - t; 00035 00036 t = tnew ; 00037 00038 return dt ; 00039 } 00040 00041 } // namespace stk_classic