Skip to content

Commit

Permalink
chore: complete benchmark scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zthxxx committed Jul 10, 2021
1 parent 9c9e8d5 commit bc1515c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"postuninstall": "npm-run-all rm-plugin:config rm-plugin:file",
"postpublish": "npm run clean",
"warn:zsh": "echo '\\n\\n!! this is a plugin for zsh, please install zsh at first \\n\\n' >&2",
"benchmark": "time ./bin/benchmark.js",
"benchmark": "./scripts/benchmark.zsh",
"rm-plugin:config": "perl -i -pe 's/.*zsh-history-enquirer.*//gms' ${HOME}/.zshrc",
"rm-plugin:file": "rm -rf ${ZSH_CUSTOM:-${ZSH}/custom}/plugins/zsh-history-enquirer"
},
Expand Down
26 changes: 26 additions & 0 deletions scripts/benchmark.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env zsh

# cwd is project root
# $ scripts/create-benchmark-history.zsh
# $ scripts/benchmark.zsh

function benchmark-run {
# https://stackoverflow.com/questions/11023929/using-the-alternate-screen-in-a-bash-script
tput smcup
for i in $(seq 1 ${1}); do
bin/benchmark.js
done
tput rmcup
}

# init test data
if [[ ! -f tests/benchmark-history.data ]]; then
scripts/create-benchmark-history.zsh
fi

# run first for nodejs cache parse
tput smcup
bin/benchmark.js
tput rmcup

time ( benchmark-run 10 times )
2 changes: 1 addition & 1 deletion scripts/create-benchmark-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# create test history data for `bin/benchmark.js`
# when cwd is project root
#
# ./scripts/create-benchmark-history.zsh
# $ scripts/create-benchmark-history.zsh

createHistory() {
local -i i=0
Expand Down

0 comments on commit bc1515c

Please sign in to comment.