Add grammar performance warning by Yanpas · Pull Request #128 · microsoft/vscode-textmate

Choose a reason for hiding this comment

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

@Yanpas
Thank you for your PR. But:

  1. This node module needs to execute in browsers and in nodejs, so we cannot use perf_hooks.
  2. We cannot just console.warn with a somewhat random time limit. VS Code ships to millions of devices with different specifications, and such a performance problem should be investigated by the grammar author, and no cycles should be spent to record duration on end users machines. In other words, IMHO, it is not useful to run this troubleshooting code all the time.

That being said, perhaps the Registry or the tokenize call can get some kind of option called "profile: true" or something. Then, only if that option is set, the times will be recorded. Then, we can adopt this in VS Code and check if running from source and then enable that flag.