(prefix, funktions, time_fn)
| 578 | |
| 579 | class ExecutionCost { |
| 580 | constructor(prefix, funktions, time_fn) { |
| 581 | this.prefix = prefix; |
| 582 | // Time spent on executed functions. |
| 583 | this.executedCost = 0; |
| 584 | // Time spent on not executed functions. |
| 585 | this.nonExecutedCost = 0; |
| 586 | this.maxDuration = 0; |
| 587 | |
| 588 | for (let i = 0; i < funktions.length; i++) { |
| 589 | const funktion = funktions[i]; |
| 590 | const value = time_fn(funktion); |
| 591 | if (funktion.hasBeenExecuted()) { |
| 592 | this.executedCost += value; |
| 593 | } else { |
| 594 | this.nonExecutedCost += value; |
| 595 | } |
| 596 | this.maxDuration = Math.max(this.maxDuration, value); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | print() { |
| 601 | console.log(this.toString()) |
nothing calls this directly
no test coverage detected