Skip to content

Instantly share code, notes, and snippets.

@glennzw
Created February 9, 2016 16:25
Show Gist options
  • Save glennzw/25cb972cfeb52e55694a to your computer and use it in GitHub Desktop.
Save glennzw/25cb972cfeb52e55694a to your computer and use it in GitHub Desktop.
Test GoProxy
#!/bin/bash
#ToDo: Learn how to use functions in Bash :P
MAXTHREADS=20
#####1. No proxy
echo "Downloading `wc -l sites.txt|xargs` sites with no proxy (max threads: $MAXTHREADS)"
start=`date +%s`
for i in `cat sites.txt`
do
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
while [ $t -ge $MAXTHREADS ]; do
sleep 0.2
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
done
curl -o ./files/$i $i --silent -m 10 &
done
end=`date +%s`
runtime=$((end-start))
echo "Done. Running time: $runtime seconds"
echo ""
rm ./files/*
#####2. mitmproxy
echo "Downloading `wc -l sites.txt|xargs` sites with mitmproxy (Python) (max threads: $MAXTHREADS)"
start=`date +%s`
for i in `cat sites.txt`
do
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
while [ $t -ge $MAXTHREADS ]; do
sleep 0.2
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
done
curl -x localhost:8090 -o ./files/$i $i --silent -m 10 &
done
end=`date +%s`
runtime=$((end-start))
echo "Done. Running time: $runtime seconds"
echo ""
rm ./files/*
#####3. GoProxy
echo "Downloading `wc -l sites.txt|xargs` sites with GoProxy (max threads: $MAXTHREADS)"
start=`date +%s`
for i in `cat sites.txt`
do
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
while [ $t -ge $MAXTHREADS ]; do
sleep 0.2
t=$(ps aux | grep curl | grep -v grep | wc -l| xargs)
done
curl -x localhost:8080 -o ./files/$i $i --silent -m 10 &
done
end=`date +%s`
runtime=$((end-start))
echo "Done. Running time: $runtime seconds"
echo ""
rm ./files/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment