Created
August 12, 2014 12:26
-
-
Save jacobsalmela/88a252e84a099f4688af to your computer and use it in GitHub Desktop.
Script performance test
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 | |
#----------AUTHOR------------ | |
# Jacob Salmela | |
# 27 March 2014 | |
# https://github.com/jakesalmela/ | |
#---------DESCRIPTION-------- | |
# Tests the performance of a script | |
#-----------USAGE------------ | |
# To run: | |
# | |
# ./script-performance-test.sh <yourScriptAsAnArgument.sh> | |
# | |
#----------VARIABLES--------- | |
# $1 will be the script to test | |
# It should be passed as an argument to this script | |
#----------FUNCTIONS--------- | |
function performanceTest() | |
{ | |
# Run this loop 10 times | |
for i in {1..10} | |
do | |
# Time the script (argument passed to this script) sending the output into the Sarlaac Pit | |
time $1 >/dev/null | |
# awk out only the last field, which is the time it took to run the script each time | |
done 2>&1 | awk '/real/ {print $2}' | |
} | |
#---------------------------------# | |
#----------BEGIN SCRIPT-----------# | |
#---------------------------------# | |
performanceTest $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment