mptensor v0.4.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1/*
2 mptensor - Parallel Library for Tensor Network Methods
3
4 Copyright 2016 Satoshi Morita
5
6 mptensor is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version.
10
11 mptensor is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with mptensor. If not, see
18 <https://www.gnu.org/licenses/>.
19*/
20
28#ifndef _TIMER_HPP_
29#define _TIMER_HPP_
30
31#include <chrono>
32
33namespace examples {
34namespace benchmark {
35
36using namespace std::chrono;
37
38class Timer {
39 public:
40 Timer(){};
41 void start() { t_start = system_clock::now(); };
42 void stop() { t_end = system_clock::now(); };
43 double result() {
44 return double(duration_cast<microseconds>(t_end - t_start).count()) * 1.0e-6;
45 };
46
47 private:
48 system_clock::time_point t_start;
49 system_clock::time_point t_end;
50};
51
52} // namespace benchmark
53} // namespace examples
54
55#endif // _TIMER_HPP_
Definition timer.hpp:38
void stop()
Definition timer.hpp:42
Timer()
Definition timer.hpp:40
double result()
Definition timer.hpp:43
void start()
Definition timer.hpp:41
Definition timer.hpp:33