getElementByID�A�ϐ��Awith�ɂ��Q�Ƒ��x��r
�y�[�W��ɂ���div�^�O���Q�Ƃ���ꍇ�̑��x��r���ʂł��BgetElementById()�ŎQ�Ƃ���ꍇ�A��x�擾����ID��ϐ��ɓ���ĎQ�Ƃ����ꍇ�Awith���g���ăI�u�W�F�N�g�����ȗ������ꍇ��3�p�^�[�����r���Ă��܂��B
�e�X�g�}�V����Power Mac G5 (2GHzx2�A������4GB)�AWindows��XP SP2 (3.0GHz�A768MB) �ōs���Ă��܂��B���쑬�x�͉��x�������[�h�����ꍇ�̒l�ɂȂ��Ă��܂��B�܂��A���쑬�x�͊��ɂ��قȂ�̂ŁA�����܂ł��Q�l���x�ɂ��Ă��������B
�y
�T���v��1�����s�z
�y
�T���v��2�����s�z
�y
�T���v��3�����s�z
OS | �u���E�U | getElementById (msec) | �ϐ� (msec) | with (msec) |
MacOS X (10.4.7) | Safari 2.0.4 | 1280 | 420 | 1000 |
MacOS X (10.4.7) | Firefox 1.5.0.4 | 4450 | 3050 | 4420 |
MacOS X (10.4.7) | Opera 9.0 | 2770 | 50 | 1160 |
Windows XP SP2 | Internet Explorer 6 | 4400 | 2300 | 2760 |
Windows XP SP2 | Firefox 1.5.0.4 | 4620 | 3032 | 4100 |
Windows XP SP2 | Opera 9.0 | 680 | 15 | 580 |
�y�T���v���P�z
��HTML�t�@�C��
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript" src="test.js"></script>
<title>Sample</title>
</head>
<body>
<p>JavaScript Speed Test</p>
<div id="outputArea"></div>
</body>
</html>
���X�N���v�g�t�@�C�� (test.js)
window.onload = function() {
var num = 100000;
s = (new Date()).getTime();
for (var i=0; i<num; i++) {
document.getElementById("outputArea").innerHTML;
}
e = (new Date()).getTime();
alert(e-s);
}
�y�T���v���Q�z
��HTML�t�@�C��
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript" src="test.js"></script>
<title>Sample</title>
</head>
<body>
<p>JavaScript Speed Test</p>
<div id="outputArea"></div>
</body>
</html>
���X�N���v�g�t�@�C�� (test.js)
window.onload = function() {
var divObj = document.getElementById("outputArea");
var num = 100000;
s = (new Date()).getTime();
for (var i=0; i<num; i++) {
divObj.innerHTML;
}
e = (new Date()).getTime();
alert(e-s);
}
�y�T���v���R�z
��HTML�t�@�C��
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript" src="test.js"></script>
<title>Sample</title>
</head>
<body>
<p>JavaScript Speed Test</p>
<div id="outputArea"></div>
</body>
</html>
���X�N���v�g�t�@�C�� (test.js)
window.onload = function() {
var divObj = document.getElementById("outputArea");
var num = 100000;
s = (new Date()).getTime();
with(document.getElementById("outputArea")) {
for (var i=0; i<num; i++) {
innerHTML;
}
}
e = (new Date()).getTime();
alert(e-s);
}