Skip to content

Instantly share code, notes, and snippets.

@mixu
Last active April 25, 2017 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mixu/e4803da16e42439480eba2b29fa44484 to your computer and use it in GitHub Desktop.
Save mixu/e4803da16e42439480eba2b29fa44484 to your computer and use it in GitHub Desktop.
Benchmark node-glob (minimatch) against the case in https://research.swtch.com/glob

Runs the test specified in https://research.swtch.com/glob

against node-glob which uses minimatch

Setup:

npm i glob
mkdir aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
chmod +x ./test.sh
./test.sh

Example (partial) result:

[regtest] ./test.sh
n,elapsed
1,0.07
2,0.07
3,0.07
4,0.07
5,0.16
6,1.43
7,19.90
8,240.76
const glob = require("glob");
const pattern = new Array(parseInt(process.argv[2], 10)).fill('a*').join('') + 'b';
//console.log(pattern);
glob(pattern, function(err, files) {});
#!/bin/sh
# You will want to brew install gnu-time since
# the default time command doesn't support formatting :(
echo "n,elapsed"
gtime -f '1,%e' node task.js 1
gtime -f '2,%e' node task.js 2
gtime -f '3,%e' node task.js 3
gtime -f '4,%e' node task.js 4
gtime -f '5,%e' node task.js 5
gtime -f '6,%e' node task.js 6
gtime -f '7,%e' node task.js 7
gtime -f '8,%e' node task.js 8
gtime -f '9,%e' node task.js 9
gtime -f '10,%e' node task.js 10
gtime -f '11,%e' node task.js 11
gtime -f '12,%e' node task.js 12
gtime -f '13,%e' node task.js 13
gtime -f '14,%e' node task.js 14
gtime -f '15,%e' node task.js 15
gtime -f '16,%e' node task.js 16
gtime -f '17,%e' node task.js 17
gtime -f '18,%e' node task.js 18
gtime -f '19,%e' node task.js 19
gtime -f '20,%e' node task.js 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment