Skip to content

Conversation

@sheetalkamat
Copy link
Member

No description provided.

return program;

function resolveModuleNamesWorker(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) {
performance.mark("beforeResolveModule");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but you could also do this:

// create once near the top of the file
const { enter: enterResolveModuleNames, exit: exitResolveModuleNames } = performance.createTimer(
    "ResolveModule",
    "beforeResolveModule",
    "afterResolveModule");
...
function resolveModuleNamesWorker(...) {
  enterResolveModuleNames();
  const result = actualResolveModuleNamesWorker(...);
  exitResolveModuleNames();
  return result;
}

You can also use performance.createTimerIf if you want to create a performance timer conditionally (such as if you only care about the metric when --extendedDiagnostics is set.

Whether you want to use createTimer is up to you.

@sheetalkamat sheetalkamat merged commit 188c3b7 into master Feb 27, 2020
@sheetalkamat sheetalkamat deleted the resolveModuleTimes branch February 27, 2020 18:22
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants