[Javascript] How to dim buttons

Hassan Schroeder hassan at webtuitive.com
Thu Nov 13 10:08:26 CST 2003


Håkan Magnusson wrote:

> Well, it's not a *billion* times faster, but this little simple test 
> case proves it to be at least 15% faster.

Running this test case "as is" in Moz FB 0.6 gave me inconsistent
results -- sometimes single being faster, sometime not. So I broke
it into individual tests to eliminate any possible interference:

-------------------------------------------------------------------
function doubleTest()
{
	var s='';
	var iTime1 = new Date().valueOf();
	for(var i=0;i<100000;i++){
		s+="a";
	}
	var iTime2 = new Date().valueOf();
	x1 = document.createTextNode('With double quote : ' + (iTime2 - iTime1));
	document.getElementById("timer1").appendChild(x1);
}
	
function singleTest()	
{
	s='';
	iTime1 = new Date().valueOf();
	for(var i=0;i<100000;i++){
		s+='a';
	}
	iTime2 = new Date().valueOf();
	x2 = document.createTextNode('With single quote : ' + (iTime2 - iTime1));
	document.getElementById("timer2").appendChild(x2);
}	
	
function init()
{
	doubleTest();    // comment out to run separately
	//singleTest();  // comment out to run separately
}

window.onload = init;
--------------------------------------------------------------------

Running this gave me substantially quicker results using double quotes
than single, in FB and Moz 1.4 (both Win). From Moz 1.4 --

double   single
  1390     2938
  1422     2281
  1391     2297
  1391     2578
  1406     2203
  1453     2515
  1657     2219
  1468     2281
  1469     2313
  1484     2250

Wow. I would have never imagined that kind of difference. Not that
it matters, since I always use double quotes anyway, as Strings in
Java must be double-quoted. But I expected either approach to show
substantially identical times...

Wierd. Maybe it's going to be one of those days :-)
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.






More information about the Javascript mailing list