Browse Source

Instrument more DoDecompile methods

pull/2519/head
Christoph Wille 4 years ago
parent
commit
6e5c474dfc
  1. 16
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 12
      ICSharpCode.Decompiler/Instrumentation/DecompilerEventSource.cs

16
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -1209,6 +1209,7 @@ namespace ICSharpCode.Decompiler.CSharp
EntityDeclaration DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) EntityDeclaration DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext)
{ {
Debug.Assert(decompilationContext.CurrentTypeDefinition == typeDef); Debug.Assert(decompilationContext.CurrentTypeDefinition == typeDef);
var watch = System.Diagnostics.Stopwatch.StartNew();
try try
{ {
var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings); var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings);
@ -1337,6 +1338,11 @@ namespace ICSharpCode.Decompiler.CSharp
{ {
throw new DecompilerException(module, typeDef, innerException); throw new DecompilerException(module, typeDef, innerException);
} }
finally
{
watch.Stop();
Instrumentation.DecompilerEventSource.Log.DoDecompileTypeDefinition(typeDef.FullName, watch.ElapsedMilliseconds);
}
} }
enum EnumValueDisplayMode enum EnumValueDisplayMode
@ -1660,6 +1666,7 @@ namespace ICSharpCode.Decompiler.CSharp
EntityDeclaration DoDecompile(IField field, DecompileRun decompileRun, ITypeResolveContext decompilationContext) EntityDeclaration DoDecompile(IField field, DecompileRun decompileRun, ITypeResolveContext decompilationContext)
{ {
Debug.Assert(decompilationContext.CurrentMember == field); Debug.Assert(decompilationContext.CurrentMember == field);
var watch = System.Diagnostics.Stopwatch.StartNew();
try try
{ {
var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings); var typeSystemAstBuilder = CreateAstBuilder(decompileRun.Settings);
@ -1722,6 +1729,11 @@ namespace ICSharpCode.Decompiler.CSharp
{ {
throw new DecompilerException(module, field, innerException); throw new DecompilerException(module, field, innerException);
} }
finally
{
watch.Stop();
Instrumentation.DecompilerEventSource.Log.DoDecompileField(field.FullName, watch.ElapsedMilliseconds);
}
} }
internal static bool IsFixedField(IField field, out IType type, out int elementCount) internal static bool IsFixedField(IField field, out IType type, out int elementCount)
@ -1802,7 +1814,7 @@ namespace ICSharpCode.Decompiler.CSharp
finally finally
{ {
watch.Stop(); watch.Stop();
Instrumentation.DecompilerEventSource.Log.DoDecompileProperty(property.Name, watch.ElapsedMilliseconds);
Instrumentation.DecompilerEventSource.Log.DoDecompileProperty(property.FullName, watch.ElapsedMilliseconds);
} }
} }
@ -1848,7 +1860,7 @@ namespace ICSharpCode.Decompiler.CSharp
finally finally
{ {
watch.Stop(); watch.Stop();
Instrumentation.DecompilerEventSource.Log.DoDecompileEvent(ev.Name, watch.ElapsedMilliseconds);
Instrumentation.DecompilerEventSource.Log.DoDecompileEvent(ev.FullName, watch.ElapsedMilliseconds);
} }
} }

12
ICSharpCode.Decompiler/Instrumentation/DecompilerEventSource.cs

@ -18,6 +18,18 @@ namespace ICSharpCode.Decompiler.Instrumentation
WriteEvent(2, propertyName, elapsedMilliseconds); WriteEvent(2, propertyName, elapsedMilliseconds);
} }
[Event(3, Level = EventLevel.Informational)]
public void DoDecompileField(string fieldName, long elapsedMilliseconds)
{
WriteEvent(3, fieldName, elapsedMilliseconds);
}
[Event(4, Level = EventLevel.Informational)]
public void DoDecompileTypeDefinition(string typeDefName, long elapsedMilliseconds)
{
WriteEvent(4, typeDefName, elapsedMilliseconds);
}
public static DecompilerEventSource Log = new DecompilerEventSource(); public static DecompilerEventSource Log = new DecompilerEventSource();
} }

Loading…
Cancel
Save