Add additional ifdefs to partial parsing tracing logic.
- Prior to this change we would be ToStringing the TextChange which resulted in 87% of successful partial parsing execution time. #800
This commit is contained in:
parent
05a52f445f
commit
d337bacc69
|
|
@ -145,10 +145,10 @@ namespace Microsoft.AspNetCore.Razor
|
||||||
/// <returns>A <see cref="PartialParseResult"/> value indicating the result of the incremental parse.</returns>
|
/// <returns>A <see cref="PartialParseResult"/> value indicating the result of the incremental parse.</returns>
|
||||||
public virtual PartialParseResult CheckForStructureChanges(TextChange change)
|
public virtual PartialParseResult CheckForStructureChanges(TextChange change)
|
||||||
{
|
{
|
||||||
|
#if EDITOR_TRACING
|
||||||
// Validate the change
|
// Validate the change
|
||||||
long? elapsedMs = null;
|
long? elapsedMs = null;
|
||||||
|
|
||||||
#if EDITOR_TRACING
|
|
||||||
var sw = new Stopwatch();
|
var sw = new Stopwatch();
|
||||||
sw.Start();
|
sw.Start();
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -161,13 +161,16 @@ namespace Microsoft.AspNetCore.Razor
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = PartialParseResult.Rejected;
|
var result = PartialParseResult.Rejected;
|
||||||
|
#if EDITOR_TRACING
|
||||||
// If there isn't already a parse underway, try partial-parsing
|
// If there isn't already a parse underway, try partial-parsing
|
||||||
var changeString = string.Empty;
|
var changeString = string.Empty;
|
||||||
|
#endif
|
||||||
using (_parser.SynchronizeMainThreadState())
|
using (_parser.SynchronizeMainThreadState())
|
||||||
{
|
{
|
||||||
|
#if EDITOR_TRACING
|
||||||
// Capture the string value of the change while we're synchronized
|
// Capture the string value of the change while we're synchronized
|
||||||
changeString = change.ToString();
|
changeString = change.ToString();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check if we can partial-parse
|
// Check if we can partial-parse
|
||||||
if (CurrentParseTree != null && _parser.IsIdle)
|
if (CurrentParseTree != null && _parser.IsIdle)
|
||||||
|
|
@ -190,13 +193,13 @@ namespace Microsoft.AspNetCore.Razor
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
elapsedMs = sw.ElapsedMilliseconds;
|
elapsedMs = sw.ElapsedMilliseconds;
|
||||||
sw.Reset();
|
sw.Reset();
|
||||||
#endif
|
|
||||||
|
|
||||||
RazorEditorTrace.TraceLine(RazorResources.FormatTrace_EditorProcessedChange(
|
RazorEditorTrace.TraceLine(RazorResources.FormatTrace_EditorProcessedChange(
|
||||||
Path.GetFileName(FileName),
|
Path.GetFileName(FileName),
|
||||||
changeString,
|
changeString,
|
||||||
elapsedMs.HasValue ? elapsedMs.Value.ToString(CultureInfo.InvariantCulture) : "?",
|
elapsedMs.HasValue ? elapsedMs.Value.ToString(CultureInfo.InvariantCulture) : "?",
|
||||||
result.ToString()));
|
result.ToString()));
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue