Created
June 10, 2012 17:11
-
-
Save n1k0/2906650 to your computer and use it in GitHub Desktop.
Silly benchmarks
This file contains hidden or 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 casper = require("casper").create(); | |
var start = new Date().getTime(); | |
var links = [ | |
"http://google.com/", | |
"http://yahoo.com/", | |
"http://bing.com/" | |
]; | |
casper.start(); | |
casper.each(links, function(self, link) { | |
this.thenOpen(link, function() { | |
var now = new Date().getTime(); | |
this.echo(link + ' loaded in ' + (now - start) + 'ms'); | |
start = now; | |
}); | |
}); | |
casper.run(); |
This file contains hidden or 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
http://google.com/ loaded in 3643ms | |
http://yahoo.com/ loaded in 12398ms | |
http://bing.com/ loaded in 1005ms |
This file contains hidden or 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 links = [ | |
"http://google.com/", | |
"http://yahoo.com/", | |
"http://bing.com/" | |
]; | |
var start = new Date().getTime(); | |
var page = require('webpage').create(); | |
page.open("http://google.com/", function() { | |
var now = new Date().getTime(); | |
console.log('loaded google in ' + (now - start) + 'ms'); | |
start = now; | |
page.open("http://yahoo.com/", function() { | |
var now = new Date().getTime(); | |
console.log('loaded yahoo in ' + (now - start) + 'ms'); | |
start = now; | |
page.open("http://bing.com/", function() { | |
var now = new Date().getTime(); | |
console.log('loaded bing in ' + (now - start) + 'ms'); | |
start = now; | |
phantom.exit(); | |
}); | |
}); | |
}); |
This file contains hidden or 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
loaded google in 4568ms | |
loaded yahoo in 10839ms | |
loaded bing in 1849ms |
casper:
```
casperjs ❯ casperjs casper_speed.js
http://google.com/ loaded in 2191ms
http://yahoo.com/ loaded in 7973ms
http://bing.com/ loaded in 1127ms
casperjs ❯ casperjs casper_speed.js
http://google.com/ loaded in 1034ms
http://yahoo.com/ loaded in 4935ms
http://bing.com/ loaded in 747ms
casperjs ❯ casperjs casper_speed.js
http://google.com/ loaded in 1184ms
http://yahoo.com/ loaded in 3853ms
http://bing.com/ loaded in 924ms
casperjs ❯ casperjs casper_speed.js
http://google.com/ loaded in 1320ms
http://yahoo.com/ loaded in 3242ms
http://bing.com/ loaded in 704ms
casperjs ❯ casperjs casper_speed.js
http://google.com/ loaded in 1412ms
http://yahoo.com/ loaded in 4360ms
http://bing.com/ loaded in 904ms
```
phantom:
```
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 2402ms
loaded yahoo in 8139ms
loaded bing in 667ms
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 760ms
loaded yahoo in 4624ms
loaded bing in 1261ms
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 2014ms
loaded yahoo in 5723ms
loaded bing in 576ms
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 633ms
loaded yahoo in 3367ms
loaded bing in 612ms
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 1254ms
loaded yahoo in 3450ms
loaded bing in 560ms
casperjs ❯ phantomjs raw_phantom_speed.js
loaded google in 572ms
loaded yahoo in 3286ms
loaded bing in 572ms
```
casperjs ❯ casperjs --disk-cache=yes casper_speed.js
http://google.com/ loaded in 1196ms
http://yahoo.com/ loaded in 3492ms
http://bing.com/ loaded in 1362ms
casperjs ❯ casperjs --disk-cache=yes casper_speed.js
http://google.com/ loaded in 659ms
http://yahoo.com/ loaded in 2451ms
http://bing.com/ loaded in 911ms
casperjs ❯ casperjs --disk-cache=yes casper_speed.js
http://google.com/ loaded in 656ms
http://yahoo.com/ loaded in 2489ms
http://bing.com/ loaded in 751ms
casperjs ❯ casperjs --disk-cache=yes casper_speed.js
http://google.com/ loaded in 656ms
http://yahoo.com/ loaded in 2571ms
http://bing.com/ loaded in 730ms
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
En tout cas, tout ceci est très lié à la qualité de la connectivité… Sinon essaye de désactiver le chargement des plugins et des images:
Le chargement des images peut pas mal altérer le temps de chargement des pages… Yu peux aussi utiliser le cache du navigateur en passant l'option
--disk-cache=yes
:(l'astuce fonctionne aussi avec phantomjs)