%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/vittasync.vacivitta.com.br/vittasync/node/benchmark/es/
Upload File :
Create Path :
Current File : /home/vacivi36/vittasync.vacivitta.com.br/vittasync/node/benchmark/es/eval.js

'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
  method: ['without-sourcemap', 'sourcemap'],
  n: [1e6],
});

const sourceWithoutSourceMap = `
'use strict';
(function() {
  let a = 1;
  for (let i = 0; i < 1000; i++) {
    a++;
  }
  return a;
})();
`;
const sourceWithSourceMap = `
${sourceWithoutSourceMap}
//# sourceMappingURL=https://ci.nodejs.org/405
`;

function evalN(n, source) {
  bench.start();
  for (let i = 0; i < n; i++) {
    eval(source);
  }
  bench.end(n);
}

function main({ n, method }) {
  switch (method) {
    case 'without-sourcemap':
      process.setSourceMapsEnabled(false);
      evalN(n, sourceWithoutSourceMap);
      break;
    case 'sourcemap':
      process.setSourceMapsEnabled(true);
      evalN(n, sourceWithSourceMap);
      break;
    default:
      throw new Error(`Unexpected method "${method}"`);
  }
}

Zerion Mini Shell 1.0