Skip to content

Instantly share code, notes, and snippets.

@LionsAd
Created October 25, 2012 11:37
Show Gist options
  • Select an option

  • Save LionsAd/3952123 to your computer and use it in GitHub Desktop.

Select an option

Save LionsAd/3952123 to your computer and use it in GitHub Desktop.
Find fastest execution time
#!/bin/bash
#
# Syntax: find-min-web.sh <namespace> <loops>
MIN=1000000
NS='drupal-perf'
LOOPS=100
[ -n "$1" ] && NS=$1
[ -n "$2" ] && LOOPS=$2
for i in $(seq 1 $LOOPS)
do
curl -s 'http://127.0.0.1/index-perf.php?q=node&extra='"$NS" | grep 'loop time: |0.'
done | while read line
do
mytime=$(echo $line | cut -d'|' -f2 | cut -d'.' -f2 | cut -d's' -f1)
if [ $mytime -lt $MIN ]
then
MIN=$mytime
echo $line
fi
LC_ALL=C sleep 0.1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment