MCPcopy
hub / github.com/webpack/webpack / registerSuite

Function registerSuite

test/BenchmarkTestCases.benchmark.mjs:955–1225  ·  view source on GitHub ↗

* @param {Bench} bench bench * @param {string} test test * @param {Baseline[]} baselines baselines * @returns {Promise<void>}

(bench, test, baselines)

Source from the content-addressed store, hash-verified

953 * @returns {Promise<void>}
954 */
955async function registerSuite(bench, test, baselines) {
956 const testDirectory = path.join(casesPath, test);
957 const optionsPath = path.resolve(testDirectory, "options.mjs");
958
959 /** @type {{ setup?: () => Promise<void> }} */
960 let options = {};
961
962 try {
963 options = await import(`${pathToFileURL(optionsPath)}`);
964 } catch (_err) {
965 // Ignore
966 }
967
968 if (typeof options.setup !== "undefined") {
969 await options.setup();
970 }
971
972 if (test.includes("-unit")) {
973 const fullBenchName = `unit benchmark "${test}"`;
974
975 console.log(`Register: ${fullBenchName}`);
976
977 const benchmarkPath = path.resolve(testDirectory, "index.bench.mjs");
978 const registerBenchmarks = await import(`${pathToFileURL(benchmarkPath)}`);
979
980 registerBenchmarks.default(bench);
981
982 return;
983 }
984
985 const realConfig = (
986 await import(
987 `${pathToFileURL(path.join(testDirectory, "webpack.config.mjs"))}`
988 )
989 ).default;
990
991 // Register sequentially so task order in `bench.tasks` is deterministic.
992 // Parallel registration makes the order depend on Promise resolution,
993 // which then leaks into the shared-process state (require.cache, webpack
994 // singletons) seen by each measurement.
995 for (const baseline of baselines) {
996 const webpack = await baseline.webpack();
997
998 for (const scenario of scenarios) {
999 const config = buildConfiguration(
1000 test,
1001 baseline,
1002 realConfig,
1003 scenario,
1004 testDirectory
1005 );
1006
1007 const stringifiedScenario = JSON.stringify(scenario);
1008 const benchName = `benchmark "${test}", scenario '${stringifiedScenario}'${LAST_COMMIT ? "" : ` ${baseline.name} (${baseline.rev})`}`;
1009 const fullBenchName = `benchmark "${test}", scenario '${stringifiedScenario}' ${baseline.name} ${baseline.rev ? `(${baseline.rev})` : ""}`;
1010
1011 console.log(`Register: ${fullBenchName}`);
1012

Calls 12

buildConfigurationFunction · 0.85
resolveFunction · 0.85
withProfilingFunction · 0.85
runWebpackFunction · 0.85
logMethod · 0.80
readFileMethod · 0.80
writeFileFunction · 0.70
resolveMethod · 0.65
addMethod · 0.45
hasWarningsMethod · 0.45
hasErrorsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected