From fe2899c2acabd2262f8b9c6230e821192ea369e3 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 8 Feb 2021 15:54:35 -0500 Subject: [PATCH] Use a 10ms sampling frequency to filter tracing dumps Currently hard-wired to 10ms, can be made configurable if needed later. --- src/compiler/tracing.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/tracing.ts b/src/compiler/tracing.ts index 41d7c8508e3..87c2abf4f48 100644 --- a/src/compiler/tracing.ts +++ b/src/compiler/tracing.ts @@ -140,12 +140,15 @@ namespace ts.tracingEnabled { // eslint-disable-line one-namespace-per-file } eventStack.length = 0; } + // sample every 10ms + const sampleInterval = 1000 * 10; function writeStackEvent(index: number, endTime: number) { const { phase, name, args, time, separateBeginAndEnd } = eventStack[index]; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, `"dur":${endTime - time}`, time); } }