libfoedus-core
FOEDUS Core Library
stop_watch.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
19 
20 #include <chrono>
21 
22 namespace foedus {
23 namespace debugging {
24 
25 uint64_t get_now_nanosec() {
26  std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now();
27  return std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
28 }
29 
31  started_ = get_now_nanosec();
32  stopped_ = started_;
33 }
34 
35 uint64_t StopWatch::stop() {
36  stopped_ = get_now_nanosec();
37  return elapsed_ns();
38 }
39 uint64_t StopWatch::peek_elapsed_ns() const {
40  return get_now_nanosec() - started_;
41 }
42 
43 } // namespace debugging
44 } // namespace foedus
void start()
Take current time tick.
Definition: stop_watch.cpp:30
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
uint64_t stop()
Take another current time tick.
Definition: stop_watch.cpp:35
uint64_t peek_elapsed_ns() const
Definition: stop_watch.cpp:39
uint64_t elapsed_ns() const
Definition: stop_watch.hpp:42
uint64_t get_now_nanosec()
Definition: stop_watch.cpp:25