adding dev folder with benchmark report
This commit is contained in:
parent
529dfce0c2
commit
6a1f2dac9d
|
@ -1,3 +1,3 @@
|
|||
*.log
|
||||
copy-test.txt
|
||||
node_modules/
|
||||
.vagrant/
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { promisify } = require('util')
|
||||
|
||||
const chunk = require('lodash.chunk')
|
||||
|
||||
const readFile = promisify(fs.readFile)
|
||||
|
||||
const extractTimestamp = line => Number(line.match(/\d+$/)[0])
|
||||
|
||||
const avg = list => list.reduce((value, item) => value += item, 0) / list.length
|
||||
|
||||
async function main () {
|
||||
const lines = (await readFile(path.resolve(__dirname, '../benchmark.log'))).toString().split('\n')
|
||||
|
||||
lines.pop()
|
||||
|
||||
const times = chunk(lines, 2).map(([start, end]) => {
|
||||
return extractTimestamp(end) - extractTimestamp(start)
|
||||
});
|
||||
|
||||
console.log(`samples:\t${times.length}`);
|
||||
console.log(`avg:\t\t${avg(times)}\tms`);
|
||||
console.log(`best:\t\t${Math.min(...times)}\tms`);
|
||||
console.log(`worst:\t\t${Math.max(...times)}\tms`);
|
||||
}
|
||||
|
||||
main()
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "tmux-fingers-dev-stuff",
|
||||
"version": "0.0.1",
|
||||
"description": "tools to develop tmux-fingers shite",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/morantron/tmux-fingers",
|
||||
"author": "Morantron",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lodash.chunk": "^4.2.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
lodash.chunk@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.chunk/-/lodash.chunk-4.2.0.tgz#66e5ce1f76ed27b4303d8c6512e8d1216e8106bc"
|
||||
integrity sha1-ZuXOH3btJ7QwPYxlEujRIW6BBrw=
|
|
@ -12,6 +12,8 @@ function snippet_for {
|
|||
echo "echo \"\$(cat /tmp/benchmark-execution-id) $1 \$((\$(date +%s%N)/1000000))\" >> ~/shared/benchmark.log"
|
||||
}
|
||||
|
||||
SAMPLES=${SAMPLES:=50}
|
||||
|
||||
function setup_benchmark_repo() {
|
||||
echo "Setting up benchmark repo ..."
|
||||
rm -rf "$benchmark_repo_path"
|
||||
|
@ -33,10 +35,14 @@ if [[ "$target" == "within-vm" ]]; then
|
|||
setup_benchmark_repo
|
||||
set_execution_id
|
||||
|
||||
cat /dev/null > ~/shared/benchmark.log
|
||||
|
||||
echo "Will run benchmark $SAMPLES times"
|
||||
|
||||
pushd "$benchmark_repo_path" &> /dev/null
|
||||
for benchmark in $(ls $benchmark_repo_path/test/benchmarks/*.sh); do
|
||||
|
||||
for i in {1..50}; do
|
||||
for i in $(seq 1 "$SAMPLES"); do
|
||||
echo "* Running $benchmark [ $i ]"
|
||||
sleep 1
|
||||
$benchmark
|
||||
|
@ -46,5 +52,6 @@ if [[ "$target" == "within-vm" ]]; then
|
|||
elif [[ -z "$target" ]]; then
|
||||
echo "Running benchmarks"
|
||||
vagrant up "$target" &>> /dev/null
|
||||
vagrant ssh "$target" -c "cd shared && ./test/benchmark.sh within-vm" 2> /dev/null
|
||||
vagrant ssh "$target" -c "cd shared && SAMPLES=$SAMPLES ./test/benchmark.sh within-vm" 2> /dev/null
|
||||
node dev/benchmark-report.js
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue