11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common.js'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 61cb0ef41Sopenharmony_ci method: ['without-sourcemap', 'sourcemap'], 71cb0ef41Sopenharmony_ci n: [1e6], 81cb0ef41Sopenharmony_ci}); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst sourceWithoutSourceMap = ` 111cb0ef41Sopenharmony_ci'use strict'; 121cb0ef41Sopenharmony_ci(function() { 131cb0ef41Sopenharmony_ci let a = 1; 141cb0ef41Sopenharmony_ci for (let i = 0; i < 1000; i++) { 151cb0ef41Sopenharmony_ci a++; 161cb0ef41Sopenharmony_ci } 171cb0ef41Sopenharmony_ci return a; 181cb0ef41Sopenharmony_ci})(); 191cb0ef41Sopenharmony_ci`; 201cb0ef41Sopenharmony_ciconst sourceWithSourceMap = ` 211cb0ef41Sopenharmony_ci${sourceWithoutSourceMap} 221cb0ef41Sopenharmony_ci//# sourceMappingURL=https://ci.nodejs.org/405 231cb0ef41Sopenharmony_ci`; 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cifunction evalN(n, source) { 261cb0ef41Sopenharmony_ci bench.start(); 271cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 281cb0ef41Sopenharmony_ci eval(source); 291cb0ef41Sopenharmony_ci } 301cb0ef41Sopenharmony_ci bench.end(n); 311cb0ef41Sopenharmony_ci} 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_cifunction main({ n, method }) { 341cb0ef41Sopenharmony_ci switch (method) { 351cb0ef41Sopenharmony_ci case 'without-sourcemap': 361cb0ef41Sopenharmony_ci process.setSourceMapsEnabled(false); 371cb0ef41Sopenharmony_ci evalN(n, sourceWithoutSourceMap); 381cb0ef41Sopenharmony_ci break; 391cb0ef41Sopenharmony_ci case 'sourcemap': 401cb0ef41Sopenharmony_ci process.setSourceMapsEnabled(true); 411cb0ef41Sopenharmony_ci evalN(n, sourceWithSourceMap); 421cb0ef41Sopenharmony_ci break; 431cb0ef41Sopenharmony_ci default: 441cb0ef41Sopenharmony_ci throw new Error(`Unexpected method "${method}"`); 451cb0ef41Sopenharmony_ci } 461cb0ef41Sopenharmony_ci} 47