File tree Expand file tree Collapse file tree 6 files changed +64
-13
lines changed Expand file tree Collapse file tree 6 files changed +64
-13
lines changed Original file line number Diff line number Diff line change 17
17
#include < sys/timeb.h>
18
18
#include " Win32/Win32Lib.h"
19
19
#include " dbgstream.h"
20
+ #include " Timer.h"
20
21
21
22
#pragma comment(lib, "Ws2_32.lib")
22
23
#pragma comment(lib, "psapi.lib")
@@ -194,20 +195,14 @@ void Output(const std::string& filename)
194
195
fs.close ();
195
196
196
197
std::cout << " writing... " << lines.size () << " lines\n " ;
197
-
198
- int i = 0 ;
199
- long t1 = getMilliCount ();
200
-
201
- for (auto s = lines.begin (); s != lines.end (); ++s)
198
+ Timer timer;
199
+ auto t1 = timer.now ();
200
+ for (const auto & s : lines)
202
201
{
203
- ++i;
204
- // auto t = s + "\n";
205
- OutputDebugStringA (s->c_str ());
206
- // Sleep(50);
202
+ OutputDebugStringA (s.c_str ());
207
203
}
208
- long t2 = getMilliCount ();
209
-
210
- std::cout << " OutputDebugStringA " << i << " lines, took: " << t2 - t1 << " ms\n " ;
204
+ auto elepsed = timer.now () - t1;
205
+ std::cout << " OutputDebugStringA " << lines.size () << " lines, took: " << static_cast <int >(Timer::ToMs (elepsed)) << " ms\n " ;
211
206
}
212
207
213
208
void EndlessTest ()
Original file line number Diff line number Diff line change 157
157
</ItemDefinitionGroup >
158
158
<ItemGroup >
159
159
<ClCompile Include =" DbgMsgSrc.cpp" />
160
+ <ClCompile Include =" Timer.cpp" />
160
161
</ItemGroup >
161
162
<ItemGroup >
162
163
<ClInclude Include =" dbgstream.h" />
164
+ <ClInclude Include =" Timer.h" />
163
165
</ItemGroup >
164
166
<ItemGroup >
165
167
<ProjectReference Include =" ..\Win32Lib\Win32Lib.vcxproj" >
Original file line number Diff line number Diff line change 18
18
<ClCompile Include =" DbgMsgSrc.cpp" >
19
19
<Filter >Source Files</Filter >
20
20
</ClCompile >
21
+ <ClCompile Include =" Timer.cpp" >
22
+ <Filter >Source Files</Filter >
23
+ </ClCompile >
21
24
</ItemGroup >
22
25
<ItemGroup >
23
26
<ClInclude Include =" dbgstream.h" >
24
27
<Filter >Header Files</Filter >
25
28
</ClInclude >
29
+ <ClInclude Include =" Timer.h" >
30
+ <Filter >Header Files</Filter >
31
+ </ClInclude >
26
32
</ItemGroup >
27
33
<ItemGroup >
28
34
<None Include =" packages.config" />
Original file line number Diff line number Diff line change
1
+ #include < stdexcept>
2
+ #include < chrono>
3
+ #include " Timer.h"
4
+
5
+ #define MICROSECONDS (1e6 / li.QuadPart)
6
+
7
+ Timer::Timer ()
8
+ : m_timerUnit(0.0 )
9
+ {
10
+ LARGE_INTEGER li;
11
+ QueryPerformanceFrequency (&li);
12
+ if (li.QuadPart == 0 )
13
+ throw std::runtime_error (" QueryPerformanceCounter not supported!" );
14
+ m_timerUnit = MICROSECONDS;
15
+ }
16
+
17
+ std::chrono::steady_clock::time_point Timer::now () const
18
+ {
19
+ return std::chrono::steady_clock::time_point (std::chrono::microseconds (static_cast <long long >(GetTicks () * m_timerUnit)));
20
+ }
21
+
22
+ long long Timer::GetTicks () const
23
+ {
24
+ LARGE_INTEGER li;
25
+ QueryPerformanceCounter (&li);
26
+ return li.QuadPart ;
27
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include < mutex>
4
+ #include < chrono>
5
+ #include < windows.h>
6
+
7
+ class Timer
8
+ {
9
+ public:
10
+ Timer ();
11
+ std::chrono::steady_clock::time_point now () const ;
12
+
13
+ static double ToMs (std::chrono::steady_clock::duration duration)
14
+ {
15
+ return static_cast <double >(std::chrono::duration_cast<std::chrono::microseconds>(duration).count ()) / 1000.0 ;
16
+ }
17
+
18
+ private:
19
+ long long GetTicks () const ;
20
+ double m_timerUnit;
21
+ };
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ private Forwarder(Package package)
53
53
InstallForwarder ( package ) ;
54
54
}
55
55
56
- private void InstallForwarder ( Package )
56
+ private void InstallForwarder ( Package package )
57
57
{
58
58
IVsOutputWindow outWindow = Package . GetGlobalService ( typeof ( SVsOutputWindow ) ) as IVsOutputWindow ;
59
59
Guid paneGuid = VSConstants . GUID_OutWindowDebugPane ; // codenotes: GUID_BuildOutputWindowPane / GUID_OutWindowDebugPane
You can’t perform that action at this time.
0 commit comments