1// LAF Base Library
2// Copyright (c) 2001-2016 David Capello
3//
4// This file is released under the terms of the MIT license.
5// Read LICENSE.txt for more information.
6
7#include <ctime>
8#include <sys/time.h>
9
10class base::Chrono::ChronoImpl {
11public:
12 ChronoImpl() {
13 reset();
14 }
15
16 void reset() {
17 gettimeofday(&m_point, NULL);
18 }
19
20 double elapsed() const {
21 struct timeval now;
22 gettimeofday(&now, NULL);
23 return (double)(now.tv_sec + (double)now.tv_usec/1000000) -
24 (double)(m_point.tv_sec + (double)m_point.tv_usec/1000000);
25 }
26
27private:
28 struct timeval m_point;
29};
30