Google Closure Compiler

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Original Code
function getRandomNumber(min, max) {
    return Math.round(Math.random() * (max - min)) + min;
}

var test = {};

test.fHVlldSRwrAKnJrOFCRe = "pBfxNriIhdvKOiKrwxqB";
test.qVVkoIIIMuTcimXtxMbW = "wfRdCmcnSiNHuQKnHwVs";
test.cSTfEGJwrXHNRCFPonsL = "sKaIkAHaXVgnhBrNmwdt";
test.JiTEAbSeidtHAJCKDqcM = "OIUGhAxArPHkorQFnOpQ";
test.qmowAmfGbDAKjLwSceuT = "frkFGfLgubvoleKjcKTw";
test.hEMpbeVHNwslwoOhDShs = "rtbFoHbQCqmlRnaLQHNx";
test.vvCSvFhvOoCIFQPjflfM = "OjrfpBldVqgoKwUJoBLv";
test.NvXMGjUmrSJkgtElITHU = "qPfegBJlwPERANiBqtqs";
test.TiGIIWaGFIVbOfnnCDMq = "hRRBAeRwHVhkxjrgaHjv";
test.XbUDVlHcdtFBSxUHtGFK = "wharSdKsiSObcadtxrNM";
test.kaLoDmCTJeKkLXmNAghS = "TfQeojoUxbIAoQLGHsDu";
test.qLoxofKjkiJRUedWOVBN = "XXikbncxbmuXFFFFMSNp";
test.bcHKrLCqobEWfNinUaRk = "gBhQcFiFcJIdERJKtIow";
test.BfWgVRWAogwQeLPSWLWp = "NBCIPudptNsEuwjfuwpC";
test.NAwMdbTDQWonXGMQUKnF = "oxbkeIXbxKiWLcDJQKgk";
test.DoGWVghUNsEBnbqBBDcg = "GxqnVNMNXaUBBXSTepNo";
test.ujidEIHpGwjArqvARXGO = "KkduOnCTGjMPmblhkpMF";
test.MQDtahmITQXgRbuJtLFH = "oKstRdDRpdKIqKDIqBwS";
test.JgRHwwooLqORSukEJmnK = "NwTkbpEAmwXUdqvfTIbE";
test.PJwOlqqUHPNiBUmJCakI = "NpQDxDhwfCqxPdthFCpx";
test.qIKFLDOwfETFHFjQRkVl = "VThXBEHfNNRFWxTkhqae";
test.NgJKsHlXGEOeJnRTqHqM = "xUspLAwcaefOSIGgJwME";
test.JIvMrllvbkBKLrHqdweV = "hWaCdVnwkmxCJffFcpbx";
test.GrFlGWBbTtQXHinIjFwh = "vaOkGhJumkVheKeRbQta";
test.AVLTcXVGAmXmHPQOctjA = "wwoNJisxCgAiDRrflwKc";
test.hiElMdllAhEtvuEfcHQJ = "GWVsmnsfhQkSwcDEwoem";
test.IFtgPoCjAOVvVcpXkRLG = "SwxdBkoXvfbFDgoCmAFA";
test.eFILURkRAudXvuQwfHSL = "AJbVCpaGmRqBOXLankLG";
test.dppALAVukLvgFoDTODBW = "PedmkeJCUFemDgbgVQBS";
test.qglfNqkOshUhusFVwqAI = "DPOJctLGwdjLhKtIxpqm";
test.WoRpTbIoBMLmxQiQodWG = "xmnvRfwLVvloPFcQhaNw";
test.PKsMrbQpwUFPiSMhCnBc = "cjNTrBDgHwtNwrljNUiM";
test.WTLrcFIfovcrCidmtcdS = "LEUGnLwktubxEWXXjvhS";
test.dTqnWKRMpprmRsHDJvnF = "EamhTThRHqoHMOumbWga";
test.EtdnQuuFatKtgAroeBCT = "aOLfoIiggfcxjEWDfwJA";
test.lUxsqGNhVlXdLwDSgvfI = "WfkpCQmdtOLWCMlrwSBl";
test.mubSXIgLdwuhGDMcLhxV = "eLUsbSEgtWmLPTFdjgqB";
test.VVKneNtVaDqdMjSQumVH = "bnnnOGKCOIwQgeAmkDkK";
test.tCQTADHipaxUiMRKMGsN = "LpxBmQujPNEgekwJSrGk";
test.TbCvntgIvdDGNHlOfWED = "NtCndvIPafbUTVtbgawL";
test.gfRScUHTgRjeJOuExWHE = "vJNamSxucOcLqRwrqNQc";
test.mmUhCPGacHpKghlnJQFO = "FGjDPrVjToULeJIvhTKb";
test.eQhAeXxqhaNimkgjXhgs = "qneMcOesGmiBKeRxKAuH";
test.RxUjLXvBXBMLOTIwwIwt = "xFlXOmtHRbiGoCiSATOe";
test.RxsNjjIWhoUILXrgdjuj = "ASMfuOQtSnWRdMGGoVad";
test.rFrTNlPSwSPciXJVechG = "dKFLdgoQMrrlNikeklSw";
test.BOiRNTvregjoEUbRddKo = "ITOJptaFHUsoUBVQVsGC";
test.npUevmOeCXwLQjAQSTtA = "iVJcDNtgAXBilRJCwQqI";
test.XOxrIGWiIGjhsjihntvi = "fOPgEUlEJiXjmHJXeemO";
test.BCFtFATCObWHtWsISOjC = "dHxjbtpPiQFVorCIFMjF";

var test = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var dict = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];

var result = dict.slice();

for (var i = -1, length = dict.length; i++ < length;)
{
    var swapIndex = getRandomNumber(i, length - 1);
    if (swapIndex !== i)
    {
        var temp = result[i];
        result [i] = result[swapIndex];
        result[swapIndex] = temp;
    }
}

var string = result.join('');

var result = [];

var length = dict.length;
while(result.length < length)
{
    var i = getRandomNumber(0, length);
    var search = dict[i];
    if(result.indexOf(search) === -1)
    {
        result.push(search);
    }
}

var string = result.join('');

var i = 0;
while (i <= test.length)
{
  var number = test[i];
  i++;
}

var i = 0,
length = test.length;
while (i <= length)
{
  var number = test[i];
  i++;
}

for(var i = 0; i <= test.length; i++)
{
  var number = test[i];
}

for(var i = 0, length = test.length; i <= length; i++)
{
  var number = test[i];
}

for(var i in test)
{
  var number = test[i];
}

for (var i = -1; ++i < test.length;) {
  var number = test[i];
}

for (var i = -1, length = test.length; ++i < length;) {
  var number = test[i];
}

test.forEach(function(number)
{

});

$.each(test, function(i, number)
{

});

_.each(test, function(number)
{

});
pending…
Whitespace only
function getRandomNumber(min,max){return Math.round(Math.random()*(max-min))+min}var test={};test.fHVlldSRwrAKnJrOFCRe="pBfxNriIhdvKOiKrwxqB";test.qVVkoIIIMuTcimXtxMbW="wfRdCmcnSiNHuQKnHwVs";test.cSTfEGJwrXHNRCFPonsL="sKaIkAHaXVgnhBrNmwdt";test.JiTEAbSeidtHAJCKDqcM="OIUGhAxArPHkorQFnOpQ";test.qmowAmfGbDAKjLwSceuT="frkFGfLgubvoleKjcKTw";test.hEMpbeVHNwslwoOhDShs="rtbFoHbQCqmlRnaLQHNx";test.vvCSvFhvOoCIFQPjflfM="OjrfpBldVqgoKwUJoBLv";test.NvXMGjUmrSJkgtElITHU="qPfegBJlwPERANiBqtqs";
test.TiGIIWaGFIVbOfnnCDMq="hRRBAeRwHVhkxjrgaHjv";test.XbUDVlHcdtFBSxUHtGFK="wharSdKsiSObcadtxrNM";test.kaLoDmCTJeKkLXmNAghS="TfQeojoUxbIAoQLGHsDu";test.qLoxofKjkiJRUedWOVBN="XXikbncxbmuXFFFFMSNp";test.bcHKrLCqobEWfNinUaRk="gBhQcFiFcJIdERJKtIow";test.BfWgVRWAogwQeLPSWLWp="NBCIPudptNsEuwjfuwpC";test.NAwMdbTDQWonXGMQUKnF="oxbkeIXbxKiWLcDJQKgk";test.DoGWVghUNsEBnbqBBDcg="GxqnVNMNXaUBBXSTepNo";test.ujidEIHpGwjArqvARXGO="KkduOnCTGjMPmblhkpMF";test.MQDtahmITQXgRbuJtLFH="oKstRdDRpdKIqKDIqBwS";
test.JgRHwwooLqORSukEJmnK="NwTkbpEAmwXUdqvfTIbE";test.PJwOlqqUHPNiBUmJCakI="NpQDxDhwfCqxPdthFCpx";test.qIKFLDOwfETFHFjQRkVl="VThXBEHfNNRFWxTkhqae";test.NgJKsHlXGEOeJnRTqHqM="xUspLAwcaefOSIGgJwME";test.JIvMrllvbkBKLrHqdweV="hWaCdVnwkmxCJffFcpbx";test.GrFlGWBbTtQXHinIjFwh="vaOkGhJumkVheKeRbQta";test.AVLTcXVGAmXmHPQOctjA="wwoNJisxCgAiDRrflwKc";test.hiElMdllAhEtvuEfcHQJ="GWVsmnsfhQkSwcDEwoem";test.IFtgPoCjAOVvVcpXkRLG="SwxdBkoXvfbFDgoCmAFA";test.eFILURkRAudXvuQwfHSL="AJbVCpaGmRqBOXLankLG";
test.dppALAVukLvgFoDTODBW="PedmkeJCUFemDgbgVQBS";test.qglfNqkOshUhusFVwqAI="DPOJctLGwdjLhKtIxpqm";test.WoRpTbIoBMLmxQiQodWG="xmnvRfwLVvloPFcQhaNw";test.PKsMrbQpwUFPiSMhCnBc="cjNTrBDgHwtNwrljNUiM";test.WTLrcFIfovcrCidmtcdS="LEUGnLwktubxEWXXjvhS";test.dTqnWKRMpprmRsHDJvnF="EamhTThRHqoHMOumbWga";test.EtdnQuuFatKtgAroeBCT="aOLfoIiggfcxjEWDfwJA";test.lUxsqGNhVlXdLwDSgvfI="WfkpCQmdtOLWCMlrwSBl";test.mubSXIgLdwuhGDMcLhxV="eLUsbSEgtWmLPTFdjgqB";test.VVKneNtVaDqdMjSQumVH="bnnnOGKCOIwQgeAmkDkK";
test.tCQTADHipaxUiMRKMGsN="LpxBmQujPNEgekwJSrGk";test.TbCvntgIvdDGNHlOfWED="NtCndvIPafbUTVtbgawL";test.gfRScUHTgRjeJOuExWHE="vJNamSxucOcLqRwrqNQc";test.mmUhCPGacHpKghlnJQFO="FGjDPrVjToULeJIvhTKb";test.eQhAeXxqhaNimkgjXhgs="qneMcOesGmiBKeRxKAuH";test.RxUjLXvBXBMLOTIwwIwt="xFlXOmtHRbiGoCiSATOe";test.RxsNjjIWhoUILXrgdjuj="ASMfuOQtSnWRdMGGoVad";test.rFrTNlPSwSPciXJVechG="dKFLdgoQMrrlNikeklSw";test.BOiRNTvregjoEUbRddKo="ITOJptaFHUsoUBVQVsGC";test.npUevmOeCXwLQjAQSTtA="iVJcDNtgAXBilRJCwQqI";
test.XOxrIGWiIGjhsjihntvi="fOPgEUlEJiXjmHJXeemO";test.BCFtFATCObWHtWsISOjC="dHxjbtpPiQFVorCIFMjF";var test=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var dict=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];var result=dict.slice();
for(var i=-1,length=dict.length;i++<length;){var swapIndex=getRandomNumber(i,length-1);if(swapIndex!==i){var temp=result[i];result[i]=result[swapIndex];result[swapIndex]=temp}}var string=result.join("");var result=[];var length=dict.length;while(result.length<length){var i=getRandomNumber(0,length);var search=dict[i];if(result.indexOf(search)===-1)result.push(search)}var string=result.join("");var i=0;while(i<=test.length){var number=test[i];i++}var i=0,length=test.length;
while(i<=length){var number=test[i];i++}for(var i=0;i<=test.length;i++)var number=test[i];for(var i=0,length=test.length;i<=length;i++)var number=test[i];for(var i in test)var number=test[i];for(var i=-1;++i<test.length;)var number=test[i];for(var i=-1,length=test.length;++i<length;)var number=test[i];test.forEach(function(number){});$.each(test,function(i,number){});_.each(test,function(number){});
pending…
Simple
function getRandomNumber(a,b){return Math.round(Math.random()*(b-a))+a}
for(var test={fHVlldSRwrAKnJrOFCRe:"pBfxNriIhdvKOiKrwxqB",qVVkoIIIMuTcimXtxMbW:"wfRdCmcnSiNHuQKnHwVs",cSTfEGJwrXHNRCFPonsL:"sKaIkAHaXVgnhBrNmwdt",JiTEAbSeidtHAJCKDqcM:"OIUGhAxArPHkorQFnOpQ",qmowAmfGbDAKjLwSceuT:"frkFGfLgubvoleKjcKTw",hEMpbeVHNwslwoOhDShs:"rtbFoHbQCqmlRnaLQHNx",vvCSvFhvOoCIFQPjflfM:"OjrfpBldVqgoKwUJoBLv",NvXMGjUmrSJkgtElITHU:"qPfegBJlwPERANiBqtqs",TiGIIWaGFIVbOfnnCDMq:"hRRBAeRwHVhkxjrgaHjv",XbUDVlHcdtFBSxUHtGFK:"wharSdKsiSObcadtxrNM",kaLoDmCTJeKkLXmNAghS:"TfQeojoUxbIAoQLGHsDu",qLoxofKjkiJRUedWOVBN:"XXikbncxbmuXFFFFMSNp",
bcHKrLCqobEWfNinUaRk:"gBhQcFiFcJIdERJKtIow",BfWgVRWAogwQeLPSWLWp:"NBCIPudptNsEuwjfuwpC",NAwMdbTDQWonXGMQUKnF:"oxbkeIXbxKiWLcDJQKgk",DoGWVghUNsEBnbqBBDcg:"GxqnVNMNXaUBBXSTepNo",ujidEIHpGwjArqvARXGO:"KkduOnCTGjMPmblhkpMF",MQDtahmITQXgRbuJtLFH:"oKstRdDRpdKIqKDIqBwS",JgRHwwooLqORSukEJmnK:"NwTkbpEAmwXUdqvfTIbE",PJwOlqqUHPNiBUmJCakI:"NpQDxDhwfCqxPdthFCpx",qIKFLDOwfETFHFjQRkVl:"VThXBEHfNNRFWxTkhqae",NgJKsHlXGEOeJnRTqHqM:"xUspLAwcaefOSIGgJwME",JIvMrllvbkBKLrHqdweV:"hWaCdVnwkmxCJffFcpbx",GrFlGWBbTtQXHinIjFwh:"vaOkGhJumkVheKeRbQta",
AVLTcXVGAmXmHPQOctjA:"wwoNJisxCgAiDRrflwKc",hiElMdllAhEtvuEfcHQJ:"GWVsmnsfhQkSwcDEwoem",IFtgPoCjAOVvVcpXkRLG:"SwxdBkoXvfbFDgoCmAFA",eFILURkRAudXvuQwfHSL:"AJbVCpaGmRqBOXLankLG",dppALAVukLvgFoDTODBW:"PedmkeJCUFemDgbgVQBS",qglfNqkOshUh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,0,0,0,0,0],dict="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(","),result=dict.slice(),i=-1,length=dict.length;i++<length;){var swapIndex=getRandomNumber(i,length-1);if(swapIndex!==i){var temp=result[i];
result[i]=result[swapIndex];result[swapIndex]=temp}}for(var string=result.join(""),result=[],length=dict.length;result.length<length;){var i=getRandomNumber(0,length),search=dict[i];-1===result.indexOf(search)&&result.push(search)}string=result.join("");for(i=0;i<=test.length;){var number=test[i];i++}i=0;for(length=test.length;i<=length;)number=test[i],i++;for(i=0;i<=test.length;i++)number=test[i];i=0;for(length=test.length;i<=length;i++)number=test[i];for(i in test)number=test[i];
for(i=-1;++i<test.length;)number=test[i];i=-1;for(length=test.length;++i<length;)number=test[i];test.forEach(function(){});$.each(test,function(){});_.each(test,function(){});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment