forked from LionsAd/xhprof-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-min-web.sh
executable file
·37 lines (34 loc) · 1.12 KB
/
find-min-web.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#
# Syntax: find-min.sh <namespace> <loops>
MIN=1000000000
NS='drupal-perf'
LOOPS=100
URL='/'
RUN_COLLECTOR=""
[ -n "$XHPROF_KIT_COLLECTOR_FILE" ] && RUN_COLLECTOR=$XHPROF_KIT_COLLECTOR_FILE
[ -n "$1" ] && NS=$1
[ -n "$2" ] && LOOPS=$2
[ -n "$3" ] && URL=$3
[ -n "$4" ] && RUN_COLLECTOR=$4
# Do one call to ensure caches are primed.
curl -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -s 'http://127.0.0.1/index-perf.php?extra='"$NS"'&url='"$URL" | grep 'loop time: |' &>/dev/null
for i in $(seq 1 $LOOPS)
do
curl -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -s 'http://127.0.0.1/index-perf.php?extra='"$NS"'&url='"$URL" | grep 'loop time: |'
done | while read line
do
mytime=$(echo $line | cut -d'|' -f2 | cut -d's' -f1 | sed 's/^/1000*1000*/' | bc | cut -d'.' -f1)
if [ $mytime -lt $MIN ]
then
MIN=$mytime
echo $line
fi
if [ -n "$RUN_COLLECTOR" ]
then
RUN_ID=$(echo $line | cut -d'|' -f3)
SANITIZED_NS=$(echo $NS | sed 's/\./_/g')
echo "${RUN_ID}|${SANITIZED_NS}" >> $RUN_COLLECTOR
fi
LC_ALL=C sleep 0.1
done