Skip to content

Instantly share code, notes, and snippets.

@josephwegner
Created July 11, 2012 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • 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`
count="0"
while [ $count -lt $2 ];
do
phantomjs ./timer.js "$1" > /dev/null 2>&1
count=$[$count + 1]
done
PHANTOMFINISH=`date +%s`
echo "PhantomJS Time: "
echo $[$PHANTOMFINISH - $PREPHANTOMTIME] seconds
echo ""
preCURLTime=`date +%s`
count="0"
while [ $count -lt $2 ];
do
curl $1 > /dev/null 2>&1
count=$[$count + 1]
done
CURLTIME=`date +%s`
echo "CURL Time: "
echo $[$CURLTIME - preCURLTime] seconds
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