Skip to content

Instantly share code, notes, and snippets.

@while-loop
Forked from josephwegner/benchmark
Last active October 20, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save while-loop/2e6bc2d6769ee13a6200d4a548ccfbb7 to your computer and use it in GitHub Desktop.
Save while-loop/2e6bc2d6769ee13a6200d4a548ccfbb7 to your computer and use it in GitHub Desktop.
Benchmark PhantomJS against cURL
#!/bin/bash
PREPHANTOMTIME=`date +%s%3N`
count="0"
while [ $count -lt $2 ];
do
phantomjs ./timer.js "$1" > /dev/null 2>&1
count=$[$count + 1]
done
PHANTOMFINISH=`date +%s%3N`
echo "PhantomJS Time: "
echo $[$PHANTOMFINISH - $PREPHANTOMTIME] millisecs
echo ""
preCURLTime=`date +%s%3N`
count="0"
while [ $count -lt $2 ];
do
curl $1 > /dev/null 2>&1
count=$[$count + 1]
done
CURLTIME=`date +%s%3N`
echo "CURL Time: "
echo $[$CURLTIME - preCURLTime] millisecs
var system = require('system');
if (system.args.length === 0) {
phantom.exit();
} else {
var page = require('webpage').create()
page.open(system.args[1], function () {
var body_innerHTML= page.evaluate( function() {
return document.body.innerHTML ? document.body.innerHTML : '(empty)' ;
});
//console.log(body_innerHTML);
phantom.exit();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment