ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
timer.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2010-2011
9  * Copyright (c) 2010-2011, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 
18 
19 #include "global.h"
20 
21 #ifndef ERKALE_TIMER
22 #define ERKALE_TIMER
23 
24 #include <ctime>
25 #include <string>
26 
27 extern "C" {
28 #include <sys/time.h>
29 }
30 
43 class Timer {
45  struct timespec tstart;
46 
48  double elapsd;
49 
51  void read(struct timespec *t) const;
52 
53  public:
55  Timer();
57  ~Timer();
58 
60  void set();
61 
63  void stop();
65  void cont();
66 
68  std::string current_time() const;
69 
71  void print() const;
73  void print_time() const;
74 
76  double get() const;
78  std::string elapsed() const;
80  std::string parse(double t) const;
81 };
82 
83 #endif
Timer()
Constructor.
Definition: timer.cpp:31
A timer routine.
Definition: timer.h:43
void stop()
Stop timer.
Definition: timer.cpp:52
std::string elapsed() const
Get pretty-printed elapsed time.
Definition: timer.cpp:102
void cont()
Continue timing.
Definition: timer.cpp:58
double elapsd
Elapsed time.
Definition: timer.h:48
std::string parse(double t) const
Get pretty-printed time.
Definition: timer.cpp:106
struct timespec tstart
Time when timer was started.
Definition: timer.h:45
void read(struct timespec *t) const
Read time.
Definition: timer.cpp:38
std::string current_time() const
Get current time.
Definition: timer.cpp:72
void print() const
Print elapsed time.
Definition: timer.cpp:68
void print_time() const
Print current time.
Definition: timer.cpp:91
~Timer()
Destructor.
Definition: timer.cpp:35
void set()
Zero timer.
Definition: timer.cpp:62