dune-pdelab 2.7-git
Loading...
Searching...
No Matches
clock.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=8 sw=2 sts=2:
3
4#ifndef DUNE_PDELAB_COMMON_CLOCK_HH
5#define DUNE_PDELAB_COMMON_CLOCK_HH
6
7#include <ostream>
8
9#include <sys/types.h>
10
11#include <dune/common/exceptions.hh>
12
13namespace Dune {
14 namespace PDELab {
15
17 struct TimeSpec {
19 time_t tv_sec;
21
24 long tv_nsec;
25
26 inline TimeSpec &operator+=(const TimeSpec &o) {
27 tv_sec += o.tv_sec;
28 tv_nsec += o.tv_nsec;
29 if(tv_nsec >= 1000000000L) {
30 ++tv_sec;
31 tv_nsec -= 1000000000L;
32 }
33 return *this;
34 }
35 inline TimeSpec operator+(const TimeSpec &o) const {
36 TimeSpec tmp(*this);
37 tmp += o;
38 return tmp;
39 }
40 inline TimeSpec &operator-=(const TimeSpec &o) {
41 tv_sec -= o.tv_sec;
42 tv_nsec -= o.tv_nsec;
43 if(tv_nsec < 0L) {
44 --tv_sec;
45 tv_nsec += 1000000000L;
46 }
47 return *this;
48 }
49 inline TimeSpec operator-(const TimeSpec &o) const {
50 TimeSpec tmp(*this);
51 tmp -= o;
52 return tmp;
53 }
54
55 };
56
58 std::ostream &operator<<(std::ostream &s, const TimeSpec &t);
59
61 struct ClockError : Exception {};
62
69 const std::string &getWallTimeImp();
76 const std::string &getProcessTimeImp();
77
78 } // namespace PDELab
79} //namespace Dune
80
81#endif // DUNE_PDELAB_COMMON_CLOCK_HH
82
const std::string s
Definition function.hh:843
For backward compatibility – Do not use this!
Definition adaptivity.hh:28
const std::string & getWallTimeImp()
return a string describing which implementation is used to get the wall time
Definition clock.cc:128
TimeSpec getProcessTime()
get the process time in seconds used by the current process
Definition clock.cc:213
const std::string & getProcessTimeImp()
return a string describing which implementation is used to get the process time
Definition clock.cc:216
std::ostream & operator<<(std::ostream &s, const TimeSpec &t)
insert a timespec into an output stream
Definition clock.cc:39
TimeSpec getWallTime()
get the wall time in seconds since the epoch
Definition clock.cc:125
TimeSpec getProcessTimeResolution()
get resolution of the process time in seconds
Definition clock.cc:214
TimeSpec getWallTimeResolution()
get resolution of the wall time in seconds
Definition clock.cc:126
struct to store temporal values
Definition clock.hh:17
TimeSpec & operator+=(const TimeSpec &o)
Definition clock.hh:26
time_t tv_sec
seconds part
Definition clock.hh:19
TimeSpec operator-(const TimeSpec &o) const
Definition clock.hh:49
TimeSpec & operator-=(const TimeSpec &o)
Definition clock.hh:40
long tv_nsec
nanoseconds part
Definition clock.hh:24
TimeSpec operator+(const TimeSpec &o) const
Definition clock.hh:35
exception thrown by clock functions
Definition clock.hh:61
Base class for all PDELab exceptions.
Definition exceptions.hh:19