00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef WINSTL_INCL_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER
00049 #define WINSTL_INCL_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER_MAJOR 4
00053 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER_MINOR 0
00054 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER_REVISION 3
00055 # define WINSTL_VER_WINSTL_PERFORMANCE_HPP_SYSTEMTIME_COUNTER_EDIT 44
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00063 # include <winstl/winstl.h>
00064 #endif
00065
00066
00067
00068
00069
00070 #ifndef _WINSTL_NO_NAMESPACE
00071 # if defined(_STLSOFT_NO_NAMESPACE) || \
00072 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00073
00074 namespace winstl
00075 {
00076 # else
00077
00078
00079 namespace stlsoft
00080 {
00081
00082 namespace winstl_project
00083 {
00084
00085 # endif
00086 #endif
00087
00088
00089
00090
00091
00096 class systemtime_counter
00097 {
00098 public:
00100 typedef systemtime_counter class_type;
00101
00102 typedef ws_sint64_t epoch_type;
00103 typedef ws_sint64_t interval_type;
00104
00105
00106 public:
00107 systemtime_counter();
00108
00109
00110 public:
00111 void start();
00112 void stop();
00113
00114
00115 public:
00116 interval_type get_period_count() const;
00117 interval_type get_seconds() const;
00118 interval_type get_milliseconds() const;
00119 interval_type get_microseconds() const;
00120
00121
00122 private:
00123 epoch_type m_start;
00124 epoch_type m_end;
00125 };
00126
00128
00129
00130 #ifdef STLSOFT_UNITTEST
00131 # include "./unittest/systemtime_counter_unittest_.h"
00132 #endif
00133
00135
00136
00137 inline systemtime_counter::systemtime_counter()
00138 {
00139
00140
00141
00142 }
00143
00144
00145 inline void systemtime_counter::start()
00146 {
00147 ::GetSystemTimeAsFileTime(reinterpret_cast<LPFILETIME>(&m_start));
00148 }
00149
00150 inline void systemtime_counter::stop()
00151 {
00152 ::GetSystemTimeAsFileTime(reinterpret_cast<LPFILETIME>(&m_end));
00153 }
00154
00155
00156 inline systemtime_counter::interval_type systemtime_counter::get_period_count() const
00157 {
00158 return static_cast<interval_type>(m_end - m_start);
00159 }
00160
00161 inline systemtime_counter::interval_type systemtime_counter::get_seconds() const
00162 {
00163 return get_period_count() / interval_type(10000000);
00164 }
00165
00166 inline systemtime_counter::interval_type systemtime_counter::get_milliseconds() const
00167 {
00168 return get_period_count() / interval_type(10000);
00169 }
00170
00171 inline systemtime_counter::interval_type systemtime_counter::get_microseconds() const
00172 {
00173 return get_period_count() / interval_type(10);
00174 }
00175
00176
00177
00178 #ifndef _WINSTL_NO_NAMESPACE
00179 # if defined(_STLSOFT_NO_NAMESPACE) || \
00180 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00181 }
00182 # else
00183 }
00184 }
00185 # endif
00186 #endif
00187
00188
00189
00190 #endif
00191
00192