Skip to content

Commit fe2899c

Browse files
committed
Use a 10ms sampling frequency to filter tracing dumps
Currently hard-wired to 10ms, can be made configurable if needed later.
1 parent f462576 commit fe2899c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/tracing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ namespace ts.tracingEnabled { // eslint-disable-line one-namespace-per-file
140140
}
141141
eventStack.length = 0;
142142
}
143+
// sample every 10ms
144+
const sampleInterval = 1000 * 10;
143145
function writeStackEvent(index: number, endTime: number) {
144146
const { phase, name, args, time, separateBeginAndEnd } = eventStack[index];
145147
if (separateBeginAndEnd) {
146148
writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
147149
}
148-
else {
150+
// test if [time,endTime) straddles a sampling point
151+
else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
149152
writeEvent("X", phase, name, args, `"dur":${endTime - time}`, time);
150153
}
151154
}

0 commit comments

Comments
 (0)