1'use strict'; 2 3const common = require('../common'); 4const fs = require('fs'); 5const path = require('path'); 6 7process.chdir(__dirname); 8const resolved_path = path.resolve(__dirname, '../../lib/'); 9const relative_path = path.relative(__dirname, '../../lib/'); 10 11const bench = common.createBenchmark(main, { 12 n: [1e4], 13 pathType: ['relative', 'resolved'], 14}); 15 16 17function main({ n, pathType }) { 18 const path = pathType === 'relative' ? relative_path : resolved_path; 19 bench.start(); 20 for (let i = 0; i < n; i++) { 21 fs.realpathSync(path); 22 } 23 bench.end(n); 24} 25