Lines 61-101javascript
62 console.error('Error: No benchmarks specified via --contracts flag or found in the [benchmark] section of Nargo.toml.');
67 console.log(`Found ${contractsToRunNames.length} benchmark(s) to run: ${contractsToRunNames.join(', ')}`);
68 // Iterate over the filtered contract names
69 for (const contractName of contractsToRunNames) {
70 const benchmarkFileName = availableBenchmarks[contractName];
71 const benchmarkFilePath = path.resolve(path.dirname(nargoTomlPath), benchmarkFileName);
72 const outputFilename = `${contractName}${suffix}.benchmark.json`;
73 const outputJsonPath = path.join(outputDir, outputFilename);
74 console.log(`--- Running benchmark for ${contractName}${suffix ? ` (suffix: ${suffix})` : ''} ---`);
75 console.log(` -> Benchmark file: ${benchmarkFilePath}`);
76 console.log(` -> Output report: ${outputJsonPath}`);
77 if (!fs.existsSync(benchmarkFilePath)) {
78 console.error(`Error: Benchmark file not found: ${benchmarkFilePath}`);
82 const module = await import(benchmarkFilePath);
83 const BenchmarkClass = module.default;
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/cli.jsView on unpkg · L81 84 if (!BenchmarkClass ||
85 !(typeof BenchmarkClass === 'function') ||
86 !(typeof BenchmarkClass.prototype.getMethods === 'function')) {
87 console.error(`Error: ${benchmarkFilePath} does not export a default class with a getMethods method.`);
90 const benchmarkInstance = new BenchmarkClass();
92 if (typeof benchmarkInstance.setup === 'function') {
93 console.log(`Running setup for ${contractName}...`);
94 runContext = await benchmarkInstance.setup();
95 console.log(`Setup complete for ${contractName}.`);
97 if (!options.skipProving && !runContext.wallet) {
98 console.error(`Error: setup() must return a context with a 'wallet' property when proving is enabled.`);
101 const profiler = new Profiler(runContext.wallet, {