(name)
| 258 | } |
| 259 | |
| 260 | stopAndReport(name) { |
| 261 | if (!instrumentationEnabled(this.config)) { |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | let instr = this._instrumentationFor(name); |
| 266 | if (!instr.token) { |
| 267 | throw new Error(`Cannot stop instrumentation "${name}". It has not started.`); |
| 268 | } |
| 269 | try { |
| 270 | instr.token.stop(); |
| 271 | } catch (e) { |
| 272 | this.ui.writeLine(chalk.red(`Error reporting instrumentation '${name}'.`)); |
| 273 | logger.error(e.stack); |
| 274 | return; |
| 275 | } |
| 276 | |
| 277 | let instrSummaryName = `_${name}Summary`; |
| 278 | if (!this[instrSummaryName]) { |
| 279 | throw new Error(`No summary found for "${name}"`); |
| 280 | } |
| 281 | |
| 282 | let tree = this._instrumentationTreeFor(name); |
| 283 | let args = Array.prototype.slice.call(arguments, 1); |
| 284 | args.unshift(tree); |
| 285 | |
| 286 | let instrInfo = { |
| 287 | summary: this[instrSummaryName].apply(this, args), |
| 288 | tree, |
| 289 | }; |
| 290 | |
| 291 | this._invokeAddonHook(name, instrInfo); |
| 292 | this._writeInstrumentation(name, instrInfo); |
| 293 | |
| 294 | if (name === 'build') { |
| 295 | instr.count++; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | function totalTime(tree) { |
no test coverage detected