-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark/profiling scripts and fixture stuff
- Loading branch information
Showing
6 changed files
with
96 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.*.swp | ||
test/a/ | ||
node_modules/* | ||
benchmark-fixture | ||
v8.log | ||
profile.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,55 @@ | ||
#!/bin/bash | ||
|
||
mkdir benchmark.$$.tmp | ||
cd benchmark.$$.tmp | ||
|
||
( | ||
set -e | ||
|
||
echo Setting up... | ||
dirnames=`echo {0..9}/{0..9}/{0..9}/{0..9}` # 10000 dirs | ||
filenames=`echo {0..9}/{0..9}/{0..9}/{0..9}/{0..9}.txt` | ||
echo $dirnames | xargs mkdir -p | ||
echo $filenames | xargs touch | ||
echo | ||
|
||
if [[ "`bash --version`" =~ version\ 4 ]]; then | ||
echo Bash timing: | ||
time bash -c 'shopt -s globstar; echo **/*.txt | wc -w' | ||
fi | ||
|
||
echo | ||
if type zsh; then | ||
echo Zsh timing: | ||
time zsh -c 'echo **/*.txt | wc -w' | ||
fi | ||
|
||
echo | ||
|
||
echo Node statSync and readdirSync timing: | ||
time node -e ' | ||
var fs=require("fs"); | ||
var count = 0; | ||
function walk (path) { | ||
if (path.slice(-4) === ".txt") count++; | ||
var stat = fs.statSync(path); | ||
if (stat.isDirectory()) { | ||
fs.readdirSync(path).forEach(function(entry) { | ||
walk(path + "/" + entry); | ||
}) | ||
} | ||
export CDPATH= | ||
|
||
bash make-benchmark-fixture.sh | ||
cd benchmark-fixture | ||
|
||
set -e | ||
|
||
if [[ "`bash --version`" =~ version\ 4 ]]; then | ||
echo Bash timing: | ||
time bash -c 'shopt -s globstar; echo **/*.txt | wc -w' | ||
fi | ||
|
||
echo | ||
if type zsh; then | ||
echo Zsh timing: | ||
time zsh -c 'echo **/*.txt | wc -w' | ||
fi | ||
|
||
echo | ||
|
||
echo Node statSync and readdirSync timing: | ||
time node -e ' | ||
var fs=require("fs"); | ||
var count = 0; | ||
function walk (path) { | ||
if (path.slice(-4) === ".txt") count++; | ||
var stat = fs.statSync(path); | ||
if (stat.isDirectory()) { | ||
fs.readdirSync(path).forEach(function(entry) { | ||
walk(path + "/" + entry); | ||
}) | ||
} | ||
walk("."); | ||
console.log(count)' | ||
echo | ||
|
||
echo Node glob.sync timing: | ||
time node -e ' | ||
var glob=require("../"); | ||
console.log(glob.sync("**/*.txt").length);' | ||
echo | ||
|
||
echo Node glob async timing: | ||
time node -e ' | ||
var glob=require("../"); | ||
glob("**/*.txt", function (er, files) { | ||
console.log(files.length) | ||
})' | ||
echo | ||
) | ||
|
||
} | ||
walk("."); | ||
console.log(count)' | ||
echo | ||
|
||
echo Node glob.sync timing: | ||
time node -e ' | ||
var glob=require("../"); | ||
console.log(glob.sync("**/*.txt").length);' | ||
echo | ||
|
||
echo Node glob async timing: | ||
time node -e ' | ||
var glob=require("../"); | ||
glob("**/*.txt", function (er, files) { | ||
console.log(files.length) | ||
})' | ||
echo | ||
|
||
echo Node glob with --prof | ||
cd .. | ||
rm -rf benchmark.$$.tmp | ||
bash prof.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
export CDPATH= | ||
set -e | ||
if ! [ -d benchmark-fixture ]; then | ||
echo Making benchmark fixtures | ||
mkdir benchmark-fixture | ||
cd benchmark-fixture | ||
dirnames=`echo {0..9}/{0..9}/{0..9}/{0..9}` # 10000 dirs | ||
filenames=`echo {0..9}/{0..9}/{0..9}/{0..9}/{0..9}.txt` | ||
echo $dirnames | xargs mkdir -p | ||
echo $filenames | xargs touch | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
export CDPATH= | ||
set -e | ||
|
||
bash make-benchmark-fixture.sh | ||
cd benchmark-fixture | ||
|
||
node --prof -e ' | ||
var glob=require("../"); | ||
glob("**/*.txt", function (er, files) { | ||
console.log(files.length) | ||
}) | ||
//console.log(glob.sync("**/*.txt").length); | ||
' | ||
mv v8.log .. | ||
node-tick-processor > profile.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters