有没有一种方法可以在VSCode中跟踪构建时间并将其记录到文本文件中

问题描述

我需要记录项目的构建时间,以在VSCode中找出平均构建时间。 例如,这就是可以在Xcode https://github.com/timroesner/BuildTimes中实现的方式。 我已经在launch.json中尝试过“ prelaunchTask”,“ postDebugTask”,但这并不是我真正需要的。

解决方法

您可以使用Compound tasks

要执行的任务是:

  1. 记录开始
  2. 构建
  3. 记录结束
{
  "version": "2.0.0","tasks": [
    {
      "label": "Start Build","type": "shell","command": "BuildTimes -start",},{
      "label": "End Build","command": "BuildTimes -end",{
      "label": "List BuildTime","command": "BuildTimes -list",{
      "label": "Build","command": "gulp","args": ["build"],"options": {
        "cwd": "${workspaceFolder}/server"
      }
    },{
      "label": "Record Build Time","dependsOrder": "sequence","dependsOn": ["Start Build","Build","End Build"]
    }
  ]
}

根据需要修改Build任务。

在launch.json中,将preLaunchTask设置为Record Build Time