File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common.js' ) ;
3+ const { posix } = require ( 'path' ) ;
4+ const assert = require ( 'assert' ) ;
5+
6+ const bench = common . createBenchmark ( main , {
7+ path : [
8+ '' ,
9+ '.' ,
10+ '/tmp/bar' ,
11+ '/home/node/..' ,
12+ posix . join ( __dirname , '/..' ) ,
13+ 'bar/baz' ,
14+ ] ,
15+ n : [ 1e5 ] ,
16+ } ) ;
17+
18+ function main ( { n, path } ) {
19+ bench . start ( ) ;
20+ let a ;
21+ for ( let i = 0 ; i < n ; i ++ ) {
22+ a = posix . toNamespacedPath ( path ) ;
23+ }
24+ bench . end ( n ) ;
25+ assert . ok ( a + 'a' ) ;
26+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common.js' ) ;
3+ const { win32 } = require ( 'path' ) ;
4+ const assert = require ( 'assert' ) ;
5+
6+ const bench = common . createBenchmark ( main , {
7+ path : [
8+ '' ,
9+ 'c:/ignore' ,
10+ 'd:\\a/b\\c/d' ,
11+ '\\e.exe' ,
12+ 'c:/blah\\blah' ,
13+ 'd:/games' ,
14+ 'c:../a' ,
15+ win32 . join ( __dirname , '/..' ) ,
16+ ] ,
17+ n : [ 1e5 ] ,
18+ } ) ;
19+
20+ function main ( { n, path } ) {
21+ bench . start ( ) ;
22+ let a ;
23+ for ( let i = 0 ; i < n ; i ++ ) {
24+ a = win32 . toNamespacedPath ( path ) ;
25+ }
26+ bench . end ( n ) ;
27+ assert . ok ( a + 'a' ) ;
28+ }
You can’t perform that action at this time.
0 commit comments