mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 10:43:51 -05:00
Tracing work
* Fix: `E` events need to have the same information that is on the
corresponding `B` events. (Superseded below.)
* Use `I` (not `i`) for instant events, so they show in devtools
too. (Though they don't go through the flame chart as they do in
`about://tracing`, so they're not nearly as useful.)
* Abstract the code that writes the records in a single `writeEvent`
local function.
* Make `args` optional, and default to `undefined` (which will not add
them) at all.
* Drop the `{ "ts": ... }` wrapper around the `args`, after verifying
that having arguments with names like `begin`, `end`, `pos`, `id`
doesn't interfere with either UIs.
* Add `tracing.push`/`tracing.pop` for complete events, change a few
`.begin`/`.end` to use these. (The caveat is that until there's an exit
handler to dump unterminated events, these won't show in the dump. When
that's done the push/pop variant can be used everywhere.)
* Add meta lines to name the process and the thread, and a line that
avoids the warning when opening in devtools.
This commit is contained in:
@@ -780,7 +780,8 @@ namespace ts {
|
||||
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
|
||||
const sourceFilesFoundSearchingNodeModules = new Map<string, boolean>();
|
||||
|
||||
tracing.begin(tracing.Phase.Program, "createProgram", {});
|
||||
const tracingData: tracing.EventData = [tracing.Phase.Program, "createProgram"];
|
||||
tracing.begin(...tracingData);
|
||||
performance.mark("beforeProgram");
|
||||
|
||||
const host = createProgramOptions.host || createCompilerHost(options);
|
||||
@@ -1032,7 +1033,7 @@ namespace ts {
|
||||
verifyCompilerOptions();
|
||||
performance.mark("afterProgram");
|
||||
performance.measure("Program", "beforeProgram", "afterProgram");
|
||||
tracing.end();
|
||||
tracing.end(...tracingData);
|
||||
|
||||
return program;
|
||||
|
||||
@@ -1590,7 +1591,8 @@ namespace ts {
|
||||
|
||||
function emitBuildInfo(writeFileCallback?: WriteFileCallback): EmitResult {
|
||||
Debug.assert(!outFile(options));
|
||||
tracing.begin(tracing.Phase.Emit, "emitBuildInfo", {});
|
||||
const tracingData: tracing.EventData = [tracing.Phase.Emit, "emitBuildInfo"];
|
||||
tracing.begin(...tracingData);
|
||||
performance.mark("beforeEmit");
|
||||
const emitResult = emitFiles(
|
||||
notImplementedResolver,
|
||||
@@ -1603,7 +1605,7 @@ namespace ts {
|
||||
|
||||
performance.mark("afterEmit");
|
||||
performance.measure("Emit", "beforeEmit", "afterEmit");
|
||||
tracing.end();
|
||||
tracing.end(...tracingData);
|
||||
return emitResult;
|
||||
}
|
||||
|
||||
@@ -1664,9 +1666,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult {
|
||||
tracing.begin(tracing.Phase.Emit, "emit", { path: sourceFile?.path });
|
||||
const tracingData: tracing.EventData = [tracing.Phase.Emit, "emit", { path: sourceFile?.path }];
|
||||
tracing.begin(...tracingData);
|
||||
const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit));
|
||||
tracing.end();
|
||||
tracing.end(...tracingData);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user