11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst fs = require('fs');
31cb0ef41Sopenharmony_ciconst path = require('path');
41cb0ef41Sopenharmony_ciconst common = require('../common.js');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst tmpdir = require('../../test/common/tmpdir');
71cb0ef41Sopenharmony_ciconst benchmarkDirectory =
81cb0ef41Sopenharmony_ci  path.resolve(tmpdir.path, 'benchmark-module-circular');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, {
111cb0ef41Sopenharmony_ci  n: [1e4],
121cb0ef41Sopenharmony_ci});
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cifunction main({ n }) {
151cb0ef41Sopenharmony_ci  tmpdir.refresh();
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  const aDotJS = path.join(benchmarkDirectory, 'a.js');
181cb0ef41Sopenharmony_ci  const bDotJS = path.join(benchmarkDirectory, 'b.js');
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  fs.mkdirSync(benchmarkDirectory);
211cb0ef41Sopenharmony_ci  fs.writeFileSync(aDotJS, 'require("./b.js");');
221cb0ef41Sopenharmony_ci  fs.writeFileSync(bDotJS, 'require("./a.js");');
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  bench.start();
251cb0ef41Sopenharmony_ci  for (let i = 0; i < n; i++) {
261cb0ef41Sopenharmony_ci    require(aDotJS);
271cb0ef41Sopenharmony_ci    require(bDotJS);
281cb0ef41Sopenharmony_ci    delete require.cache[aDotJS];
291cb0ef41Sopenharmony_ci    delete require.cache[bDotJS];
301cb0ef41Sopenharmony_ci  }
311cb0ef41Sopenharmony_ci  bench.end(n);
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  tmpdir.refresh();
341cb0ef41Sopenharmony_ci}
35