diff --git a/package.json b/package.json index ddfb78b..0f4746e 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,12 @@ "description": "command to open your preferred file browser. Use the ${traceDir} substitution variable", "order": 8 }, + "tsperf.tracer.slowTypeThresholdMs": { + "type": "number", + "default": 100, + "description": "Types taking longer than this many milliseconds will be highlighted as slow/complex", + "order": 9 + }, "tsperf.tracer.traceTimeThresholds": { "type": "object", "properties": { diff --git a/src/index.ts b/src/index.ts index ced41cc..e3d722f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -233,7 +233,10 @@ async function runDiagnostics(collection: vscode.DiagnosticCollection, filePath: const duration = durations.reduce((a, b) => a + b, 0) / durations.length const proportionalTime = duration / baseline - if (proportionalTime > 1) { + const config = vscode.workspace.getConfiguration('tsperf.tracer') + const slowThreshold = config.get('slowTypeThresholdMs', 100) + + if (proportionalTime > 1 || duration > slowThreshold) { const comparisonPercentage = Math.round(proportionalTime * 100) - 100 const sign = comparisonPercentage > 1 ? '+' : '' const logLevel = proportionalTime > 2