MCPcopy
hub / github.com/webpack/webpack / runTaskSync

Function runTaskSync

test/BenchmarkTestCases.benchmark.mjs:761–809  ·  view source on GitHub ↗
(task, name, uri)

Source from the content-addressed store, hash-verified

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

Callers 1

withCodSpeedFunction · 0.85

Calls 10

iterationFunction · 0.85
wrapWithInstrumentHooksFunction · 0.85
wrapFunctionWithFrameFunction · 0.85
logTaskCompletionFunction · 0.85
taskCompletionMessageFunction · 0.85
logMethod · 0.80
getMethod · 0.45
callMethod · 0.45
pushMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected