원본 출처 : http://www.rockstarapps.com/samples/performance/

javascript 다양한 로우레벨 퍼포먼스 테스트를 한 사이트가 있네요.
자주 사용하는 부분이 Array와 HTML! 부분인데 사용에 따라 1초 이상 걸리는 경우들도 있네요.
클라이언트 사양에 따라 많이 다르겠지만 저는 이런 테스트 결과가 나왔네요.

ARRAY
Description Total Time (ms) Per/Call (ms)
Array access
Array index value change
Empty Array index value change
Empty Array add three values
Empty Array with set size
Empty Array using constructor

Push element onto an Array x5000
Pop element of an Array x5000
Push element onto an Array x5000
Shift elements off the front of an Array x100
Join the array into a string (4900)
Push element onto an Array x100
Sorting of an Array x1000

Math.max(7.25,7.30)
Math.min(7.25,7.30)
47
63
125
140
157
140

31
954
31
172
15
94
78

63
78
0.00235
0.00315
0.00625
0.007
0.00785
0.007

0.0062
0.1908
0.0062
1.72
15
0.0047
0.078

0.00315
0.0039

HTML!
Description Total Time (ms) Per/Call (ms)
Change text using innerHTML (1000x)
Create a text node on HTML Dom (1000x)
Change the class name of an element (1000x)

getElementById
getElementsByTagName("div")
getElementsByTagName("spa")
getElementsByName

placeDiv.getAttribute("id") x20000
placeDiv.attributes["id"] x20000
var atts = placeDiv.attributes; atts["id"].name x20000
var atts = placeDiv.attributes; atts.id.name x20000
188
141
265

1406
2531
2407
1453

453
485
187
172
0.188
0.141
0.265

0.0703
0.12655
0.12035
0.07265

0.02265
0.02425
0.00935
0.0086


This application tests the performance of many different low level calls. Knowing how each browser will perform on basic functionality will allow developers to create best practices for code in their JavaScript library.

You will be amazed at how fast you can make your application go by understanding the basic performance characteristics of the JavaScript language. Also it is important not to just run these test on Firefox, but on all browsers to see the difference between them. Feel free to modify the code to test other things that you may have found to be problematic.

The absolute times are not important and will vary from run to run. What is important is the difference in times between browsers and between two different ways to do the same thing. Performance tuning you application will take time, you can use the jsLex project to help out when you need to quickly find a bottleneck in your code..
신고
Posted by Rhio.kim