Created
July 11, 2012 03:35
Benchmark PhantomJS against cURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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