-
Notifications
You must be signed in to change notification settings - Fork 26
/
benchmark.js
executable file
·50 lines (41 loc) · 1.28 KB
/
benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
'use strict';
var rimraf = require('rimraf');
var fs = require('fs');
var childProcess = require('child_process');
var walkSync = require('./');
rimraf.sync('benchmark.tmp');
var directories = 100, files = 1000;
function createDirWithFiles(dir) {
fs.mkdirSync(dir);
for (var i = 0; i < files; i++) {
fs.writeFileSync(dir + '/' + i, 'foo');
}
}
console.log('Creating ' + (directories * files) + ' files across ' + directories + ' directories');
createDirWithFiles('benchmark.tmp');
for (var i = 0; i < directories - 1; i++) {
createDirWithFiles('benchmark.tmp/dir' + i);
}
childProcess.spawnSync('sync');
console.time('walkSync');
for (i = 0; i < 5; i++) {
walkSync('benchmark.tmp');
}
console.timeEnd('walkSync');
console.time('walkSync with **/* glob');
for (i = 0; i < 5; i++) {
walkSync('benchmark.tmp', ['**/*']);
}
console.timeEnd('walkSync with **/* glob');
console.time('walkSync with **/*DOESNOTMATCH glob');
for (i = 0; i < 5; i++) {
walkSync('benchmark.tmp', ['**/*DOESNOTMATCH']);
}
console.timeEnd('walkSync with **/*DOESNOTMATCH glob');
console.time('walkSync with DOESNOTMATCH*/** glob');
for (i = 0; i < 5; i++) {
walkSync('benchmark.tmp', ['DOESNOTMATCH*/**']);
}
console.timeEnd('walkSync with DOESNOTMATCH*/** glob');
rimraf.sync('benchmark.tmp');