Last active
August 24, 2017 23:45
-
-
Save dgholz/b21cf7c569dad6c7073cec9dfd1f48fd to your computer and use it in GitHub Desktop.
Performance comparison test script for https://github.com/dgholz/detect_virtualenv/issues/13
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
#!/bin/bash | |
function switch_branch() { | |
for branch in master f/fast_find | |
do | |
git -C ~/.vendor/detect_virtualenv checkout $branch >/dev/null 2>&1 | |
. ~/.vendor/detect_virtualenv/detect_virtualenv 2>/dev/null | |
$@ $branch | |
done | |
} | |
function start_in_dirs() { | |
base=$(mktemp -d /tmp/tmp.XXXXXX) | |
trap 'rm -rf base' EXIT | |
mydirs=($base foo bar baz quux quuux bie bletch) | |
( IFS=/; mkdir -p "${mydirs[*]}" ) | |
mkdir "$base/target" | |
for depth in $( seq 0 ${#mydirs[@]} ) | |
do | |
cd ${mydirs[$depth]} | |
$@ $depth | |
done | |
} | |
function set_virtualenv_names() { | |
for names in $( seq 1 9 ) | |
do | |
export MY_VIRTUALENV_NAMES=$( ( seq 1 $name; echo target ) | paste -sd':' - ) | |
$@ $names | |
done | |
} | |
function time_it() { | |
local c=$1; shift | |
( IFS=,; echo -n "$*," ) | |
( time $c >/dev/null ) 2>&1 | grep real | awk '{ print $2 }' | sed -e's/m/*60000 + /' -e's/s$/*1000/' | bc | cut -f1 -d. | |
} | |
function main() { | |
echo "branch,dir_depth,candidate_count,duration" | |
switch_branch start_in_dirs set_virtualenv_names time_it detect_virtualenv | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment