| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 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 | + 'src/index.ts', | ||
| 9 | + 'src/index.test.ts', | ||
| 10 | + 'src/foo/bar/biz/baz/index.test.ts', | ||
| 11 | + ], | ||
| 12 | + pattern: [ | ||
| 13 | + 'src/**/baz/*.test.ts', | ||
| 14 | + 'src/**/baz/*.ts', | ||
| 15 | + 'test/**/*.ts', | ||
| 16 | + ], | ||
| 17 | + n: [1e5], | ||
| 18 | + }); | ||
| 19 | + | ||
| 20 | + function main({ path, pattern, n }) { | ||
| 21 | + bench.start(); | ||
| 22 | + let a; | ||
| 23 | + for (let i = 0; i < n; i++) { | ||
| 24 | + a = posix.matchesGlob(path, pattern); | ||
| 25 | + } | ||
| 26 | + bench.end(n); | ||
| 27 | + assert(a + 'a'); | ||
| 28 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 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 | + 'src/index.ts', | ||
| 9 | + 'src\\index.ts', | ||
| 10 | + 'src/foo/bar/biz/baz/index.test.ts', | ||
| 11 | + 'src\\foo\\bar\\biz\\baz\\index.test.ts', | ||
| 12 | + ], | ||
| 13 | + pattern: [ | ||
| 14 | + 'src/**/baz/*.test.ts', | ||
| 15 | + 'src/**/baz/*.ts', | ||
| 16 | + 'test/**/*.ts', | ||
| 17 | + ], | ||
| 18 | + n: [1e5], | ||
| 19 | + }); | ||
| 20 | + | ||
| 21 | + function main({ path, pattern, n }) { | ||
| 22 | + bench.start(); | ||
| 23 | + let a; | ||
| 24 | + for (let i = 0; i < n; i++) { | ||
| 25 | + a = win32.matchesGlob(path, pattern); | ||
| 26 | + } | ||
| 27 | + bench.end(n); | ||
| 28 | + assert(a + 'a'); | ||
| 29 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments