File tree Expand file tree Collapse file tree 5 files changed +70
-12
lines changed Expand file tree Collapse file tree 5 files changed +70
-12
lines changed Original file line number Diff line number Diff line change @@ -84,17 +84,17 @@ public void QueueLogMessage(Models.LogMsg msg)
8484 }
8585
8686
87- // try
88- // {
89-
90- // if (string.IsNullOrEmpty(msg.Th))
91- // {
92- // msg.Th = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
93- // }
94- // }
95- // catch
96- // {
97- // }
87+ try
88+ {
89+
90+ if ( string . IsNullOrEmpty ( msg . Th ) )
91+ {
92+ msg . Th = System . Threading . Thread . CurrentThread . ManagedThreadId . ToString ( ) ;
93+ }
94+ }
95+ catch
96+ {
97+ }
9898
9999#if NET45 || NET40
100100 try
Original file line number Diff line number Diff line change 55using System . Runtime . Serialization ;
66using System . Text ;
77using Newtonsoft . Json ;
8+ using StackifyLib . Utils ;
89
910namespace StackifyLib . Models
1011{
@@ -51,7 +52,10 @@ public class LogMsg
5152
5253 public LogMsg ( )
5354 {
54- EpochMs = ( long ) DateTime . UtcNow . Subtract ( _Epoch ) . TotalMilliseconds ;
55+ EpochMs = ( long ) HighPrecisionTime . UtcNow . Subtract ( _Epoch ) . TotalMilliseconds ;
56+
57+ //Switched to high precision timer
58+ //EpochMs = (long)DateTime.UtcNow.Subtract(_Epoch).TotalMilliseconds;
5559 UploadErrors = 0 ;
5660 }
5761
Original file line number Diff line number Diff line change @@ -90,6 +90,14 @@ public static void SetOperationName(string operationName)
9090
9191 }
9292
93+ [ Obsolete ( "Just used for testing" , false ) ]
94+ [ MethodImpl ( MethodImplOptions . PreserveSig | MethodImplOptions . NoInlining | MethodImplOptions . NoOptimization ) ]
95+ public static void NoOp ( )
96+ {
97+
98+ }
99+
100+
93101
94102 [ MethodImpl ( MethodImplOptions . PreserveSig | MethodImplOptions . NoInlining | MethodImplOptions . NoOptimization ) ]
95103 public static void TraceString ( string logMsg )
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Runtime . InteropServices ;
5+ using System . Threading . Tasks ;
6+
7+ namespace StackifyLib . Utils
8+ {
9+ public static class HighPrecisionTime
10+ {
11+ public static bool IsAvailable { get ; private set ; }
12+
13+ [ DllImport ( "Kernel32.dll" , CallingConvention = CallingConvention . Winapi ) ]
14+ private static extern void GetSystemTimePreciseAsFileTime ( out long filetime ) ;
15+
16+ public static DateTime UtcNow
17+ {
18+ get
19+ {
20+ if ( ! IsAvailable )
21+ {
22+ return DateTime . UtcNow ;
23+ // throw new InvalidOperationException("High resolution clock isn't available.");
24+ }
25+ long filetime ;
26+ GetSystemTimePreciseAsFileTime ( out filetime ) ;
27+ return DateTime . FromFileTimeUtc ( filetime ) ;
28+ }
29+ }
30+
31+ static HighPrecisionTime ( )
32+ {
33+ try
34+ {
35+ long filetime ;
36+ GetSystemTimePreciseAsFileTime ( out filetime ) ;
37+ IsAvailable = true ;
38+ }
39+ catch
40+ {
41+ IsAvailable = false ;
42+ }
43+ }
44+ }
45+ }
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ internal static ProfilerType GetProfilerType()
5757 switch ( process ? . ProcessName ? . ToLower ( ) . Replace ( ".vshost" , "" ) )
5858 {
5959 case "devdashservice" :
60+ case "stackifytracerservice" :
6061 case "stackifytracernotifier" :
6162 case "devdashtestconsole" :
6263 _LastProfilerType = ProfilerType . Prefix ;
You can’t perform that action at this time.
0 commit comments