Skip to content

Instantly share code, notes, and snippets.

@josephwegner
Created July 11, 2012 03:35
Show Gist options
  • Save josephwegner/3087830 to your computer and use it in GitHub Desktop.
Save josephwegner/3087830 to your computer and use it in GitHub Desktop.
Benchmark PhantomJS against cURL
#!/bin/bash
PREPHANTOMTIME=`date +%s%N | cut -b1-13`
count="0"
while [ $count -lt $2 ];
do
phantomjs --load-images=no ./timer.js "$1" > /dev/null 2>&1
count=$[$count + 1]
echo -ne "."
done
PHANTOMFINISH=`date +%s%N | cut -b1-13`
echo ""
preCURLTime=`date +%s%N | cut -b1-13`
count="0"
while [ $count -lt $2 ];
do
curl $1 > /dev/null 2>&1
count=$[$count + 1]
echo -ne "."
done
CURLTIME=`date +%s%N | cut -b1-13`
echo ""
echo ""
echo "PhantomJS Time: "
echo $[$PHANTOMFINISH - $PREPHANTOMTIME] milliseconds
echo ""
echo "CURL Time: "
echo $[$CURLTIME - preCURLTime] milliseconds
var page = require('webpage').create(),
t, address;
if (phantom.args.length === 0) {
phantom.exit();
} else {
address = phantom.args[0];
page.open(address, function (status) {
phantom.exit();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment