(task, name, uri)
| 759 | * @param {string} uri URI |
| 760 | */ |
| 761 | const runTaskSync = (task, name, uri) => { |
| 762 | let { fn, options } = |
| 763 | /** @type {TaskMeta} */ |
| 764 | (uriMap.get(name)); |
| 765 | |
| 766 | // Custom setup |
| 767 | bench.setup?.(task, "run"); |
| 768 | |
| 769 | options?.beforeAll?.call(task, "run"); |
| 770 | |
| 771 | if ( |
| 772 | codspeedRunnerMode === "simulation" || |
| 773 | codspeedRunnerMode === "memory" |
| 774 | ) { |
| 775 | // Custom warmup — see the async path for rationale. |
| 776 | const samples = []; |
| 777 | |
| 778 | while (samples.length < warmupIterations) { |
| 779 | samples.push(iteration(task, name)); |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | options?.beforeEach?.call(task, "run"); |
| 784 | |
| 785 | // Multiple GC passes so finalization (and any allocations finalizers |
| 786 | // trigger) doesn't leak into the measured sample. The sync path has no |
| 787 | // microtask queue to drain, so we just chain GCs. |
| 788 | for (let i = 0; i < 4; i++) { |
| 789 | global.gc?.(); |
| 790 | } |
| 791 | wrapWithInstrumentHooks(wrapFunctionWithFrame(fn, false), uri); |
| 792 | |
| 793 | options?.afterEach?.call(task, "run"); |
| 794 | console.log(`[Codspeed] ✔ Measured ${uri}`); |
| 795 | options?.afterAll?.call(task, "run"); |
| 796 | |
| 797 | // Custom teardown |
| 798 | bench.teardown?.(task, "run"); |
| 799 | |
| 800 | logTaskCompletion(uri, taskCompletionMessage()); |
| 801 | |
| 802 | // Release this task's closures |
| 803 | fn = NO_OP_FN; |
| 804 | options = undefined; |
| 805 | uriMap.delete(name); |
| 806 | for (let i = 0; i < 4; i++) { |
| 807 | global.gc?.(); |
| 808 | } |
| 809 | }; |
| 810 | |
| 811 | /** |
| 812 | * @returns {Task[]} tasks |
no test coverage detected