11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ciconst { win32 } = require('path'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 61cb0ef41Sopenharmony_ci paths: [ 71cb0ef41Sopenharmony_ci ['C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'].join('|'), 81cb0ef41Sopenharmony_ci ['C:\\', 'D:\\'].join('|'), 91cb0ef41Sopenharmony_ci ['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'), 101cb0ef41Sopenharmony_ci ['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'), 111cb0ef41Sopenharmony_ci ['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|'), 121cb0ef41Sopenharmony_ci ], 131cb0ef41Sopenharmony_ci n: [1e5], 141cb0ef41Sopenharmony_ci}); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cifunction main({ n, paths }) { 171cb0ef41Sopenharmony_ci let to = ''; 181cb0ef41Sopenharmony_ci const delimIdx = paths.indexOf('|'); 191cb0ef41Sopenharmony_ci if (delimIdx > -1) { 201cb0ef41Sopenharmony_ci to = paths.slice(delimIdx + 1); 211cb0ef41Sopenharmony_ci paths = paths.slice(0, delimIdx); 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci bench.start(); 251cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 261cb0ef41Sopenharmony_ci if (i % 3 === 0) 271cb0ef41Sopenharmony_ci win32.relative(`${paths}${i}`, `${to}${i}`); 281cb0ef41Sopenharmony_ci else 291cb0ef41Sopenharmony_ci win32.relative(paths, to); 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci bench.end(n); 321cb0ef41Sopenharmony_ci} 33