diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 42144c5e6..1cffa39ea 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -1744,6 +1744,7 @@ namespace ICSharpCode.Decompiler.CSharp EntityDeclaration DoDecompile(IProperty property, DecompileRun decompileRun, ITypeResolveContext decompilationContext) { Debug.Assert(decompilationContext.CurrentMember == property); + var watch = System.Diagnostics.Stopwatch.StartNew(); try { var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings); @@ -1798,11 +1799,17 @@ namespace ICSharpCode.Decompiler.CSharp { throw new DecompilerException(module, property, innerException); } + finally + { + watch.Stop(); + Instrumentation.DecompilerEventSource.Log.DoDecompileProperty(property.Name, watch.ElapsedMilliseconds); + } } EntityDeclaration DoDecompile(IEvent ev, DecompileRun decompileRun, ITypeResolveContext decompilationContext) { Debug.Assert(decompilationContext.CurrentMember == ev); + var watch = System.Diagnostics.Stopwatch.StartNew(); try { var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings); @@ -1838,6 +1845,11 @@ namespace ICSharpCode.Decompiler.CSharp { throw new DecompilerException(module, ev, innerException); } + finally + { + watch.Stop(); + Instrumentation.DecompilerEventSource.Log.DoDecompileEvent(ev.Name, watch.ElapsedMilliseconds); + } } #region Sequence Points diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index 7ebd56f7c..2c31e5b87 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -100,6 +100,7 @@ + diff --git a/ICSharpCode.Decompiler/Instrumentation/DecompilerEventSource.cs b/ICSharpCode.Decompiler/Instrumentation/DecompilerEventSource.cs new file mode 100644 index 000000000..902dcc4d0 --- /dev/null +++ b/ICSharpCode.Decompiler/Instrumentation/DecompilerEventSource.cs @@ -0,0 +1,24 @@ +using System; +using System.Diagnostics.Tracing; + +namespace ICSharpCode.Decompiler.Instrumentation +{ + [EventSource(Name = "ICSharpCode.Decompiler")] + public sealed class DecompilerEventSource : EventSource + { + [Event(1, Level = EventLevel.Informational)] + public void DoDecompileEvent(string eventName, long elapsedMilliseconds) + { + WriteEvent(1, eventName, elapsedMilliseconds); + } + + [Event(2, Level = EventLevel.Informational)] + public void DoDecompileProperty(string propertyName, long elapsedMilliseconds) + { + WriteEvent(2, propertyName, elapsedMilliseconds); + } + + public static DecompilerEventSource Log = new DecompilerEventSource(); + } + +}