(output = (v) => console.log(v))
| 63 | * @description Example usage |
| 64 | */ |
| 65 | const ExampleIntervalTimer = function (output = (v) => console.log(v)) { |
| 66 | /** |
| 67 | * Create am object with default settings. |
| 68 | * @type {IntervalTimer} Used to get timing information. |
| 69 | */ |
| 70 | const timer = new IntervalTimer() |
| 71 | timer.startTimer() |
| 72 | |
| 73 | // ... Initialization code ... |
| 74 | // I generally use it for timing tests in Jasmine JS. |
| 75 | |
| 76 | /** |
| 77 | * Gets the runtime till this point. |
| 78 | * Can be subtracted from ElapsedTime to offset timing of initialization code. |
| 79 | */ |
| 80 | const initOffset = timer.getRunTime() |
| 81 | |
| 82 | // ... A test ... |
| 83 | // The time taken to run the test. |
| 84 | output(timer.getElapsedTime(initOffset)) |
| 85 | |
| 86 | /** |
| 87 | * Returns the elapsed time and resets the timer to 0. |
| 88 | */ |
| 89 | output(timer.resetTimer()) |
| 90 | } |
| 91 | |
| 92 | export { IntervalTimer, ExampleIntervalTimer } |
nothing calls this directly
no test coverage detected