@@ -34,12 +34,17 @@ bool StartTraceSession()
34
34
gMRConsumer = new MRTraceConsumer (args.mTrackDisplay );
35
35
}
36
36
37
+ if (args.mOutputDateTime ) {
38
+ gSession .mTimestampType = TraceSession::TIMESTAMP_TYPE_SYSTEM_TIME;
39
+ } else {
40
+ gSession .mTimestampType = TraceSession::TIMESTAMP_TYPE_QPC;
41
+ }
42
+
37
43
// Start the session;
38
44
// If a session with this same name is already running, we either exit or
39
45
// stop it and start a new session. This is useful if a previous process
40
46
// failed to properly shut down the session for some reason.
41
- auto timestampType = args.mOutputDateTime ? TraceSession::TIMESTAMP_TYPE_SYSTEM_TIME : TraceSession::TIMESTAMP_TYPE_QPC;
42
- auto status = gSession .Start (gPMConsumer , gMRConsumer , args.mEtlFileName , args.mSessionName , timestampType);
47
+ auto status = gSession .Start (gPMConsumer , gMRConsumer , args.mEtlFileName , args.mSessionName );
43
48
if (status == ERROR_ALREADY_EXISTS) {
44
49
if (args.mStopExistingSession ) {
45
50
PrintWarning (
@@ -61,7 +66,7 @@ bool StartTraceSession()
61
66
62
67
status = TraceSession::StopNamedSession (args.mSessionName );
63
68
if (status == ERROR_SUCCESS) {
64
- status = gSession .Start (gPMConsumer , gMRConsumer , args.mEtlFileName , args.mSessionName , timestampType );
69
+ status = gSession .Start (gPMConsumer , gMRConsumer , args.mEtlFileName , args.mSessionName );
65
70
}
66
71
}
67
72
@@ -164,12 +169,13 @@ double TimestampToSeconds(uint64_t timestamp)
164
169
165
170
void TimestampToLocalSystemTime (uint64_t timestamp, SYSTEMTIME* st, uint64_t * ns)
166
171
{
167
- /* if not TIMESTAMP_TYPE_SYSTEM_TIME
168
- auto tns = (timestamp - gSession.mStartTimestamp.QuadPart) * 1000000000ull / gSession.mTimestampFrequency.QuadPart;
169
- auto ft = gSession.mStartFileTime + (tns / 100);
170
- FileTimeToSystemTime((FILETIME const*) &ft, st);
171
- *ns = tns % 1000000000;
172
- */
173
- FileTimeToSystemTime ((FILETIME const *) ×tamp, st);
172
+ if (gSession .mTimestampType != TraceSession::TIMESTAMP_TYPE_SYSTEM_TIME) {
173
+ auto delta100ns = (timestamp - gSession .mStartTimestamp .QuadPart ) * 10000000ull / gSession .mTimestampFrequency .QuadPart ;
174
+ timestamp = gSession .mStartFileTime + delta100ns;
175
+ }
176
+
177
+ FILETIME lft{};
178
+ FileTimeToLocalFileTime ((FILETIME*) ×tamp, &lft);
179
+ FileTimeToSystemTime (&lft, st);
174
180
*ns = (timestamp % 10000000 ) * 100 ;
175
181
}
0 commit comments