NanoStructures  1.0
DMFT solver for layered, strongly correlated nanostructures
timer.h
Go to the documentation of this file.
1 #ifndef TIMER_H
2 #define TIMER_H
3 
12 /*
13  * Copyright (c) 2014 Christoph Schuette.
14  *
15  * The license and distribution terms for this file may be
16  * found in the file LICENSE in this distribution
17  */
18 
19 #include <sys/time.h>
20 
21 namespace debug {
22 
26  class Timer {
27  public:
28 
29  Timer() {
30  gettimeofday(&m_start, NULL);
31  }
32 
36  void start() {
37  gettimeofday(&m_start, NULL);
38  }
39 
44  double elapsed() {
45  gettimeofday(&m_end, NULL);
46  return (m_end.tv_sec + m_end.tv_usec * 1e-6) -
47  (m_start.tv_sec + m_start.tv_usec * 1e-6);
48  }
49  protected:
50  struct timeval m_start, m_end;
51 
52  };
53 }
54 
55 #endif // TIMER_H
A simple timer class.
Definition: timer.h:26
void start()
saves the current time as the start time.
Definition: timer.h:36
double elapsed()
determines the elapsed time since start time.
Definition: timer.h:44