1'use strict'; 2const common = require('../common.js'); 3const { win32 } = require('path'); 4 5const bench = common.createBenchmark(main, { 6 props: [ 7 ['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|'), 8 ], 9 n: [1e6], 10}); 11 12function main({ n, props }) { 13 props = props.split('|'); 14 const obj = { 15 root: props[0] || '', 16 dir: props[1] || '', 17 base: '', 18 ext: props[3] || '', 19 name: '', 20 }; 21 22 bench.start(); 23 for (let i = 0; i < n; i++) { 24 obj.base = `a${i}${props[2] || ''}`; 25 obj.name = `a${i}${props[4] || ''}`; 26 win32.format(obj); 27 } 28 bench.end(n); 29} 30