Created
October 10, 2012 10:49
-
-
Save peterjmit/3864743 to your computer and use it in GitHub Desktop.
Revisions
-
peterjmit revised this gist
Oct 10, 2012 . 1 changed file with 1 addition and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ #!/bin/bash # REQUIRES SUDO # Benchmark runner repeats=20 output_file='benchmark_results.csv' command_to_run='echo 1' run_tests() { # -------------------------------------------------------------------------- @@ -30,12 +30,6 @@ run_tests() { sync && echo 3 > /proc/sys/vm/drop_caches echo -ne ${l}' ('${p}'%) \r' done; echo -ne '\n' -
peterjmit created this gist
Oct 10, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ #!/bin/bash # Benchmark runner repeats=20 output_file='benchmark_results.csv' command_to_run='echo 1' test_dir='test_files' run_tests() { # -------------------------------------------------------------------------- # Benchmark loop # -------------------------------------------------------------------------- echo 'Benchmarking ' $command_to_run '...'; # Indicate the command we just run in the csv file echo '======' $command_to_run '======' >> $output_file; # Run the given command [repeats] times for (( i = 1; i <= $repeats ; i++ )) do # percentage completion p=$(( $i * 100 / $repeats)) # indicator of progress l=$(seq -s "+" $i | sed 's/[0-9]//g') # runs time function for the called script, output in a comma seperated # format output file specified with -o command and -a specifies append /usr/bin/time -f "%E,%U,%S" -o ${output_file} -a ${command_to_run} > /dev/null 2>&1 # Clear the HDD cache (I hope?) sync && echo 3 > /proc/sys/vm/drop_caches echo -ne ${l}' ('${p}'%) \r' if [ -d "$test_dir" ]; then # remove any files created # rm $test_dir/*; /usr/bin/find $test_dir -mindepth 1 -delete fi done; echo -ne '\n' # Convenience seperator for file echo '--------------------------' >> $output_file } # Option parsing while getopts n:c:o: OPT do case "$OPT" in n) repeats=$OPTARG ;; o) output_file=$OPTARG ;; c) command_to_run=$OPTARG run_tests ;; \?) echo 'No arguments supplied' exit 1 ;; esac done shift `expr $OPTIND - 1`