Skip to content

Commit

Permalink
Added qps.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
w32zhong committed Sep 8, 2016
1 parent 5503092 commit ede35e7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/qps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
function show_progress() {
# calculate time interval
cur_t=`date +%s`
t0=`cat "qps-t0.log"`
let "t = cur_t - t0"

tot=`wc -l qps-tot.log | awk '{print $1}'`
suc=`wc -l qps-suc.log | awk '{print $1}'`
echo "${t} sec: success rate: ${suc}/${tot}"
if [ $t -ne 0 ]; then
echo -n 'QPS: '
awk "BEGIN {print ${suc}/${t}}"
fi
}

function do_curl() {
url="$1"
curl "${url}" >> qps.log 2>> /dev/null && echo 'good' >> qps-suc.log
echo 'done' >> qps-tot.log
}

#url='http://www.baidu.com/s?wd=%E6%B2%A1%E6%9C%89%E5%B9%B6%E4%B8%8D'
url='https://approach0.xyz/search/search-relay.php?p=1&q=%24%5Cmin(d(x%2Cy)%2C2)%24%2C%20metric%20space'

> qps.log
> qps-tot.log
> qps-suc.log

date +%s > "qps-t0.log"

for i in `seq 1 100`; do
(do_curl "$url"; show_progress) &
done

0 comments on commit ede35e7

Please sign in to comment.