1 /*****************************************************************************
2  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
3  *                                                                           *
4  *   This program is free software; you can redistribute it and/or modify    *
5  *   it under the terms of the GNU Lesser General Public License as          *
6  *   published by the Free Software Foundation; either version 2.1 of the    *
7  *   License, or (at your option) version 3, or any later version accepted   *
8  *   by the membership of KDE e.V. (or its successor approved by the         *
9  *   membership of KDE e.V.), which shall act as a proxy defined in          *
10  *   Section 6 of version 3 of the license.                                  *
11  *                                                                           *
12  *   This program is distributed in the hope that it will be useful,         *
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
15  *   Lesser General Public License for more details.                         *
16  *                                                                           *
17  *   You should have received a copy of the GNU Lesser General Public        *
18  *   License along with this library. If not,                                *
19  *   see <http://www.gnu.org/licenses/>.                                     *
20  *****************************************************************************/
21 
22 #ifndef _QTC_UTILS_TIMER_H_
23 #define _QTC_UTILS_TIMER_H_
24 
25 #include "log.h"
26 #include <cinttypes>
27 
28 namespace QtCurve {
29 
30 uint64_t getTime();
31 uint64_t getElapse(uint64_t prev);
32 void tic();
33 uint64_t toc();
34 static inline void
printTime(uint64_t time)35 printTime(uint64_t time)
36 {
37     qtcForceLog("Time: %" PRIu64 "\n", time);
38 }
39 static inline void
printElapse(uint64_t prev)40 printElapse(uint64_t prev)
41 {
42     printTime(getElapse(prev));
43 }
44 static inline void
printToc()45 printToc()
46 {
47     printTime(toc());
48 }
49 
50 }
51 
52 #endif
53