MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / runBenchmark

Function runBenchmark

scripts/benchmark/main.ts:56–138  ·  view source on GitHub ↗
(benchArgs: BenchArgs)

Source from the content-addressed store, hash-verified

54`;
55
56export async function runBenchmark(benchArgs: BenchArgs): Promise<void> {
57 const {
58 scenarioPath,
59 command,
60 init,
61 useLocal,
62 forceCheckout,
63 forcePublish,
64 precompile,
65 prepare,
66 ignoreFailure,
67 showOutput,
68 warmup,
69 exportJson,
70 memFile,
71 e2eCloneDirectory,
72 } = benchArgs;
73
74 const scenario = loadScenario(e2eCloneDirectory, scenarioPath);
75
76 if (scenario.definition.disabled === true) {
77 logWarning(`Scenario "${scenario.id}" is disabled`);
78 return;
79 }
80
81 const benchCommand = command ?? scenario.definition.defaultCommand;
82 const runs = benchArgs.runs ?? 10;
83
84 if (init) {
85 logStep("Initializing scenario");
86 await e2eInit(
87 e2eCloneDirectory,
88 scenarioPath,
89 useLocal,
90 forceCheckout,
91 forcePublish,
92 );
93 }
94
95 if (precompile) {
96 logStep("Precompiling (npx hardhat compile)");
97 await e2eExec(
98 e2eCloneDirectory,
99 scenarioPath,
100 "npx hardhat compile",
101 useLocal,
102 forceCheckout,
103 forcePublish,
104 );
105 }
106
107 logStep("Running benchmark");
108 const hyperfineCommand = buildHyperfineCommand(
109 benchCommand,
110 warmup,
111 runs,
112 prepare,
113 ignoreFailure,

Callers 2

runPhaseFunction · 0.90
cliMainFunction · 0.85

Calls 7

loadScenarioFunction · 0.90
logWarningFunction · 0.90
logStepFunction · 0.90
logFunction · 0.90
wrapWithTimeFunction · 0.90
buildHyperfineCommandFunction · 0.85
pkgMethod · 0.80

Tested by

no test coverage detected