Problog
This post cover the following topics:
- Song of the post
- Code for testing Javascript engine
- Results
Song of the Post – James Blackshaw – Cross
I decided to combine my two favorite things – javascript and music. So I’ll try to add a song which either i listened to during the writing of the post, or i just kept listening to it over and over so i decided to let you enjoy it as well (or not, your choice).
It is recommended to read the post while listening to the song (some say it is even better just to listen to the song, i’m just saying…)
So this post is hosting James Blackshaw, the gifted guitarist and pianist from London:
Couple of days ago a friend of mine came to watch a football (or as known to the Americans as soccer) game. The game was so boring that we started to talk about man stuff – who has the biggest, or in our case who is the fastest. After the game was over (thank god) i wanted to know which of the browsers has the most fastest javascript engine. i decided to run a little test of my own.
The Test Code
In order to test the javascript engine of each browser i created a page with an inline javascript code. i decided to check how each browser perform with string manipulation. I wrote two functions that do the same thing:
function strAdd1(){
var start = new Date().valueOf();
var str = "This is the string that will be tested. it is a long one with numbers 1234567890";
for(var i=0;i<100000;i++){
str += "This is the string that will be tested. it is a long one with numbers 1234567890";
}
return new Date().valueOf() - start;
}
function strAdd2(){
var start = new Date().valueOf();
var str = new Array();
for(var i=0;i<100000;i++){
str[str.length] = "This is the string that will be tested. it is a long one with numbers 1234567890";
}
var s = str.join("");
return new Date().valueOf() - start;
}
function runTest(){
var results = "Test Results<br>";
results += "Time for string concotation: " + strAdd1() + "<br>";
results += "Time for Array Join: " + strAdd2() + "<br>";
document.getElementById("results").innerHTML = results;
}
addStr1 adds 10,000 times a string using regular string concatenation operator (+).
addStr2 creates an array and adds a new string to the end of the array 10,000 times. at the end it creates the same string as addStr1 does, using the join method. I know this is not the ultimate benchmark for javascript engine (nor even close) but i just wanted to validate my feelings about each browser.
I then ran the test on the following browsers:
- firefox 3.5.7
- IE8 8.0
- safari 4.0.4
- Chrome 4.0
The results

as you can see Chrome left all the others way behind, and to my surpriseĀ firefox is lagging behind. What’s interesting to me is that i thought that the concatenation string (addStr1) would be much slower then strAdd2, but to my surprise it had much better results. I guess this is due to the fact that browser manufactures have really put an emphasis on javascript performance, and if we would test this code on IE6 and other old browser the picture would be much different.
So my friend won the argument but still, i’ll take firefox over any browser no matter how fast it is.
If you think of another function to add to the test, please write it in the comments to share it with everyone, and maybe i’ll add it to the post.
Cheers – and go Firefox!









very cool & good post, thank you very much for sharing.
Link | February 4th, 2010 at 4:58 am
Amir,
It would be interesting to correlate your tests vs http://www2.webkit.org/perf/sunspider-0.9/sunsp…
A few other tests would be interesting, if you have the time and interest in doing so. First would be Javascript crypto operations. Check out: http://crypto.stanford.edu/sjcl/
Another would be DOM access and manipulation. e.g. how fast is each browser at getting a collection of elements and then extracting the values from them. See http://dromaeo.com/
Link | February 23rd, 2010 at 4:39 pm
Thanks for the info.
I might use it to write a more comprehensive Javascript engine benchmark.
Link | February 24th, 2010 at 11:57 pm
Thanks for the info.
I might use it to write a more comprehensive Javascript engine benchmark.
Link | February 25th, 2010 at 6:57 am
RONALD wrote:
PillSpot.org. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Pillspot.org. Vitamins@buy.online” rel=”nofollow”>.…
Categories: Blood Pressure/Heart.Pain Relief.Skin Care.Antidiabetic.Stomach.Vitamins/Herbal Supplements.Antidepressants.Weight Loss.Womens Health.Eye Care.Mens Health.Stop SmokingAnxiety/Sleep Aid.Anti-allergic/Asthma.Mental HealthAntiviral.Antibi…
Link | June 26th, 2010 at 8:58 am
FERNANDO wrote:
Buy:Zovirax.100% Pure Okinawan Coral Calcium.Valtrex.Lumigan.Mega Hoodia.Arimidex.Human Growth Hormone.Prevacid.Synthroid.Petcam (Metacam) Oral Suspension.Zyban.Prednisolone.Actos.Accutane.Nexium.Retin-A….
Link | July 4th, 2010 at 2:06 am
BRYAN wrote:
Buy:Ventolin.Female Cialis.Cozaar.Aricept.Zetia.SleepWell.Advair.Lasix.Lipitor.Nymphomax.Female Pink Viagra.Benicar.Buspar.Zocor.Seroquel.Acomplia.Wellbutrin SR.Amoxicillin.Lipothin.Prozac….
Link | July 21st, 2010 at 3:16 pm
CAMERON wrote:
Buy:Arimidex.Prednisolone.Mega Hoodia.Synthroid.Prevacid.Zovirax.Valtrex.Human Growth Hormone.Nexium.Zyban.100% Pure Okinawan Coral Calcium.Retin-A.Petcam (Metacam) Oral Suspension.Accutane.Lumigan.Actos….
Link | September 5th, 2010 at 12:24 pm
CHRISTOPHER wrote:
Buy:VPXL.Cialis Professional.Viagra Super Active+.Viagra.Soma.Viagra Soft Tabs.Tramadol.Cialis Soft Tabs.Super Active ED Pack.Cialis Super Active+.Propecia.Viagra Super Force.Cialis.Viagra Professional.Zithromax.Maxaman.Levitra….
Link | September 6th, 2010 at 8:44 am
MITCHELL wrote:
…
BUY FASHION. TOP BRANDS: GUCCI, DOLCE&GABBANA, BURBERRY, DIESEL, ICEBERG, ROBERTO CAVALLI, EMPORIO ARMANI, VERSACE…
Link | November 11th, 2010 at 6:11 pm