Skip to content

Commit 96423b8

Browse files
committed
Log: More precise timing
1 parent ba131ff commit 96423b8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Src/StartMenu/StartMenuDLL/LogManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#include "ResourceHelper.h"
1010
#include "ComHelper.h"
1111
#include <propvarutil.h>
12+
#include <chrono>
1213

1314
int g_LogCategories;
1415
static FILE *g_LogFile;
15-
static int g_LogTime;
16+
static std::chrono::time_point<std::chrono::steady_clock> g_LogTime;
1617

1718
void InitLog( int categories, const wchar_t *fname )
1819
{
@@ -23,7 +24,7 @@ void InitLog( int categories, const wchar_t *fname )
2324
wchar_t bom=0xFEFF;
2425
fwrite(&bom,2,1,g_LogFile);
2526
g_LogCategories=categories;
26-
g_LogTime=GetTickCount();
27+
g_LogTime=std::chrono::steady_clock::now();
2728
LogMessage(L"version=%x, PID=%d, TID=%d, Categories=%08x\r\n",GetWinVersion(),GetCurrentProcessId(),GetCurrentThreadId(),categories);
2829
}
2930
}
@@ -40,7 +41,7 @@ void LogMessage( const wchar_t *text, ... )
4041
if (!g_LogFile) return;
4142

4243
wchar_t buf[2048];
43-
int len=Sprintf(buf,_countof(buf),L"%8d: ",GetTickCount()-g_LogTime);
44+
int len=Sprintf(buf,_countof(buf),L"%8d: ",std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now()-g_LogTime).count());
4445
fwrite(buf,2,len,g_LogFile);
4546

4647
va_list args;

0 commit comments

Comments
 (0)