1 /* ///////////////////////////////////////////////////////////////////////
7 * Brief: tick_counter class - precision: ms
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_PLATFORM_WIN_TICK_COUNTER_H
13 #define EXTL_PLATFORM_WIN_TICK_COUNTER_H
15 /*!\file tick_counter.h
16 * \brief tick_counter class - precision: ms
19 # error tick_counter.h need be supported by c++.
22 /* ///////////////////////////////////////////////////////////////////////
27 /* ///////////////////////////////////////////////////////////////////////
28 * ::extl::platform::win namespace
30 EXTL_WIN_BEGIN_WHOLE_NAMESPACE
32 /*!\brief tick_counter class
33 * \ingroup extl_group_counter
37 /// \name Constructors
47 typedef tick_counter class_type
;
49 #ifdef EXTL_64BIT_INT_SUPPORT
50 typedef e_uint64_t interval_type
;
52 typedef e_uint32_t interval_type
;
54 typedef DWORD size_type
;
67 inline interval_type
count() const;
68 inline interval_type
seconds() const;
69 inline interval_type
ms() const;
70 inline interval_type
us() const;
81 /* ///////////////////////////////////////////////////////////////////////
82 * Class implementation
84 inline tick_counter::tick_counter()
89 inline tick_counter::~tick_counter()
92 inline void tick_counter::begin()
94 m_begin
= ::GetTickCount();
97 inline void tick_counter::end()
99 m_end
= ::GetTickCount();
101 inline tick_counter::interval_type
tick_counter::count() const
103 EXTL_ASSERT(m_end
>= m_begin
);
104 return static_cast<interval_type
>(m_end
- m_begin
);
106 inline tick_counter::interval_type
tick_counter::seconds() const
108 return count() / interval_type(1000);
110 inline tick_counter::interval_type
tick_counter::ms() const
114 inline tick_counter::interval_type
tick_counter::us() const
116 return count() * interval_type(1000);
119 /* ///////////////////////////////////////////////////////////////////////
122 #ifdef EXTL_COUNTER_TICK_COUNTER_TEST_ENABLE
123 # include "unit_test/tick_counter_test.h"
126 /* ///////////////////////////////////////////////////////////////////////
127 * ::extl::platform::win namespace
129 EXTL_WIN_END_WHOLE_NAMESPACE
131 /* //////////////////////////////////////////////////////////////////// */
132 #endif /* EXTL_PLATFORM_WIN_TICK_COUNTER_H */
133 /* //////////////////////////////////////////////////////////////////// */