* 테스트 환경
- Windows 7 64bit
- STS 3.2.0 ( VMware vFabric tc Server Developer Edition v2.7 )
- 크롬 27.0.1
- IE 10
- IE 9 (IE 10 개발자도구)
- IE 8 (IE 10 개발자도구)
- IE 7 (IE 10 개발자도구)
- jQuery 1.9.0
- jQuery ui 1.10.3
- jqGrid 4.5.2
개요 |
다음은 jQuery 의 Grid 플러그인인 jqGrid 의 gridview 옵션 적용시 성능 차이에 대한 결과를 리포트하는데 목적이 있습니다. jqGrid의 WIKI에서 말하고 있는 gridview에 대한 검증 차원도 있습니다.
gridview : In the previous versions of jqGrid including 3.4.X, reading a relatively large data set (number of rows >= 100 ) caused speed problems. The reason for this was that as every cell was inserted into the grid we applied about 5 to 6 jQuery calls to it. Now this problem is resolved; we now insert the entry row at once with a jQuery append. The result is impressive - about 3 to 5 times faster. What will be the result if we insert all the data at once? Yes, this can be done with a help of gridview option (set it to true). The result is a grid that is 5 to 10 times faster. Of course, when this option is set to true we have some limitations. If set to true we can not use treeGrid, subGrid, or the afterInsertRow event. If you do not use these three options in the grid you can set this option to true and enjoy the speed.
link -> http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
준비 |
0. jqGrid Demo 사이트에서 샘플코드를 이용하여 테스트 준비
1. JSON 테스트를 위한 코드 준비
HTML
<div id="jsonSpeed"></div>
<table id="jsonGrid"></table>
Script
<script>
jQuery("#jsonGrid").jqGrid({
url:'../data/data.json',
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55},
{name:'invdate',index:'invdate', width:90},
{name:'name',index:'name asc, invdate', width:100},
{name:'amount',index:'amount', width:80, align:"right"},
{name:'tax',index:'tax', width:80, align:"right"},
{name:'total',index:'total', width:80,align:"right"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum: -1,
gridview:true,
rownumbers:true,
rowList:[10,20,30],
sortorder: "desc",
gridComplete : function() {
var tm = jQuery("#jsonGrid").jqGrid('getGridParam','totaltime');
$("#jsonSpeed").html("Render time: "+ tm+" ms ");
},
caption:"JSON Example"
});
</script>
2. XML 테스트를 위한 코드 준비
HTML
<div id="xmlSpeed"></div>
<table id="xmlGrid"></table>
Script
<script>
jQuery("#xmlGrid").jqGrid({
url: '../data/data.xml',
datatype: "xml",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:55},
{name:'invdate',index:'invdate', width:90},
{name:'name',index:'name asc, invdate', width:100},
{name:'amount',index:'amount', width:80, align:"right"},
{name:'tax',index:'tax', width:80, align:"right"},
{name:'total',index:'total', width:80,align:"right"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum: -1,
gridview:true,
rownumbers:true,
rowList:[10,20,30],
sortorder: "desc",
gridComplete : function() {
var tm = jQuery("#xmlGrid").jqGrid('getGridParam','totaltime');
$("#xmlSpeed").html("Render time: "+ tm+" ms ");
},
caption: "XML example"
});
</script>
3. 데이터 수(10, 100, 200, 500, 1000)에 따라 5번 수행하여 평균값을 이용하여 브라우저별 비교 실행 : (code minimization 은 생략)
data | 10 | 100 | 200 | 500 | 1000 |
XML | 3 KB | 21 KB | 41 KB | 102 KB | 204 KB |
JSON | 3 KB | 27 KB | 53 KB | 133 KB | 265 KB |
결과 |
마치며 |
참고 |
jqGrid (http://www.trirand.com/blog/)
- jqGrid Demo (http://www.trirand.com/blog/jqgrid/jqgrid.html)
'Tip > Javascript' 카테고리의 다른 글
[Thymeleaf] contextPath in Javascript (0) | 2013.11.07 |
---|---|
[jqGrid] getRowData 를 이용시 \r\n 값이 사라지는 현상 in IE8 (0) | 2013.10.30 |
국내 오픈소스 WYSIWYG HTML 에디터 (0) | 2013.10.08 |
[jQuery] MouseWheel event (0) | 2013.09.23 |
[jQuery] form data binding (0) | 2013.08.27 |