1 /* ///////////////////////////////////////////////////////////////////////
7 * Brief: The tick_counter class - precision: ms
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_PLATFORM_WINDOWS_TICK_COUNTER_H
13 #define EXTL_PLATFORM_WINDOWS_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::windows namespace
30 EXTL_WINDOWS_BEGIN_WHOLE_NAMESPACE
32 /*!\brief tick_counter class
34 * \ingroup extl_group_counter
38 /// \name Constructors
47 typedef tick_counter class_type
;
48 typedef DWORD size_type
;
49 #ifdef EXTL_64BIT_INT_SUPPORT
50 typedef e_uint64_t interval_type
;
52 typedef e_uint32_t interval_type
;
73 inline interval_type
count() const;
74 inline interval_type
s() const;
75 inline interval_type
ms() const;
76 inline interval_type
us() const;
80 /* ///////////////////////////////////////////////////////////////////////
81 * Class implementation
83 inline tick_counter::tick_counter()
84 : m_start(0), m_stop(0)
87 inline void tick_counter::start()
89 m_start
= ::GetTickCount();
91 inline void tick_counter::stop()
93 m_stop
= ::GetTickCount();
95 inline tick_counter::interval_type
tick_counter::count() const
97 EXTL_ASSERT(m_stop
>= m_start
);
98 return static_cast<interval_type
>(m_stop
- m_start
);
100 inline tick_counter::interval_type
tick_counter::s() const
102 return count() / interval_type(1000);
104 inline tick_counter::interval_type
tick_counter::ms() const
108 inline tick_counter::interval_type
tick_counter::us() const
110 return count() * interval_type(1000);
113 /* ///////////////////////////////////////////////////////////////////////
114 * ::extl::platform::windows namespace
116 EXTL_WINDOWS_END_WHOLE_NAMESPACE
118 /* //////////////////////////////////////////////////////////////////// */
119 #endif /* EXTL_PLATFORM_WINDOWS_TICK_COUNTER_H */
120 /* //////////////////////////////////////////////////////////////////// */