11cb0ef41Sopenharmony_ci// Tests the impact on eager operations required for policies affecting 21cb0ef41Sopenharmony_ci// general startup, does not test lazy operations 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ciconst fs = require('node:fs'); 51cb0ef41Sopenharmony_ciconst common = require('../common.js'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst tmpdir = require('../../test/common/tmpdir.js'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst benchmarkDirectory = tmpdir.fileURL('benchmark-import'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst configs = { 121cb0ef41Sopenharmony_ci n: [1e3], 131cb0ef41Sopenharmony_ci specifier: [ 141cb0ef41Sopenharmony_ci 'data:text/javascript,{i}', 151cb0ef41Sopenharmony_ci './relative-existing.js', 161cb0ef41Sopenharmony_ci './relative-nonexistent.js', 171cb0ef41Sopenharmony_ci 'node:prefixed-nonexistent', 181cb0ef41Sopenharmony_ci 'node:os', 191cb0ef41Sopenharmony_ci ], 201cb0ef41Sopenharmony_ci}; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst options = { 231cb0ef41Sopenharmony_ci flags: ['--expose-internals'], 241cb0ef41Sopenharmony_ci}; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, configs, options); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciasync function main(conf) { 291cb0ef41Sopenharmony_ci tmpdir.refresh(); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci fs.mkdirSync(benchmarkDirectory, { recursive: true }); 321cb0ef41Sopenharmony_ci fs.writeFileSync(new URL('./relative-existing.js', benchmarkDirectory), '\n'); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci bench.start(); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci for (let i = 0; i < conf.n; i++) { 371cb0ef41Sopenharmony_ci try { 381cb0ef41Sopenharmony_ci await import(new URL(conf.specifier.replace('{i}', i), benchmarkDirectory)); 391cb0ef41Sopenharmony_ci } catch { /* empty */ } 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci bench.end(conf.n); 431cb0ef41Sopenharmony_ci} 44