11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common.js'); 41cb0ef41Sopenharmony_ciconst modPath = require.resolve('../fixtures/simple-error-stack.js'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 71cb0ef41Sopenharmony_ci method: ['without-sourcemap', 'sourcemap'], 81cb0ef41Sopenharmony_ci n: [1e5], 91cb0ef41Sopenharmony_ci}); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifunction runN(n) { 121cb0ef41Sopenharmony_ci delete require.cache[modPath]; 131cb0ef41Sopenharmony_ci const mod = require(modPath); 141cb0ef41Sopenharmony_ci bench.start(); 151cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 161cb0ef41Sopenharmony_ci mod.simpleErrorStack(); 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci bench.end(n); 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cifunction main({ n, method }) { 221cb0ef41Sopenharmony_ci switch (method) { 231cb0ef41Sopenharmony_ci case 'without-sourcemap': 241cb0ef41Sopenharmony_ci process.setSourceMapsEnabled(false); 251cb0ef41Sopenharmony_ci runN(n); 261cb0ef41Sopenharmony_ci break; 271cb0ef41Sopenharmony_ci case 'sourcemap': 281cb0ef41Sopenharmony_ci process.setSourceMapsEnabled(true); 291cb0ef41Sopenharmony_ci runN(n); 301cb0ef41Sopenharmony_ci break; 311cb0ef41Sopenharmony_ci default: 321cb0ef41Sopenharmony_ci throw new Error(`Unexpected method "${method}"`); 331cb0ef41Sopenharmony_ci } 341cb0ef41Sopenharmony_ci} 35