Faster And Lighter, The Performance Test On ZK8
James Chu, Engineer, Potix Corporation
September 2015
ZK 8.0
Introduction
In the upcoming ZK 8, we have done a lot of performance tuning in both server side and client side. To determine the difference of performance between ZK 7 and ZK 8, we arrange a test, using MVVM and children binding to generate 30 * 30 <div>s and <label>s. Moreover, we use the new feature - Shadow element in ZK 8 to generate the same components. About the testing tools, we use JMeter to record the average response time, and VisualVM to record the memory consumption of each test case.
Test Environment
The following paragraph includes the hardware spec of this test, required software, and corresponding parameters.
- Hardware
- CPU: 2.9 GHz Intel Core i5
- Memory: 16.00 GB
- Software
- ZK 7.0.6 CE
- ZK 8.0.0 CE FL (20150914)
- ZK 8.0.0 EE FL (20150914)
- Jetty -7.6.8.v20121106
- JDK 1.7.0.80
- Apache JMeter 2.12
- Visual VM 1.3.8
- Configurations
- Jetty
- -Xms8096m
- -Xmx8096m
- JMeter
- 100, 200, 400, 600, 800, 1000, 1200, 1500 concurrent threads in 1 second
- Jetty
Test Plan
There are two test cases in this performance test. First, we use children binding and MVVM to generate 30 * 30 <div>s and <label>s, and switch three versions: ZK 7.0.6 EE, ZK 8.0.0 CE, and ZK 8.0.0 EE. Second, we use the Shadow element to generate the same amount of components. Testing is done by monitoring that there are 100 to 1500 concurrent users accessing the page.
Test Case
The whole performance testing project for this article can be found in github.
children-binding.zul:
<?component name="wizard" templateURI="/WEB-INF/zul/template/wizard/wizard.zul" ?>
<zk>
<div id="bind" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('org.zkoss.ForEachVM')">
<div id="host" style="display:none">
<div children="@load(vm.array)">
<template name="children">
<div children="@load(vm.array)">
<template name="children">
Test Label
</template>
</div>
</template>
</div>
</div>
</div>
</zk>
ForEachVM.java:
public class ForEachVM {
private static List<Integer> array = Collections.nCopies(30, 30);
public void setArray(List<Integer> array) {}
public List<Integer> getArray() {
return array;
}
}
forEach.zul
<?component name="wizard" templateURI="/WEB-INF/zul/template/wizard/wizard.zul" ?>
<zk>
<div id="bind" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('org.zkoss.ForEachVM')">
<div id="host" style="display:none">
<forEach items="@load(vm.array)">
<div>
<forEach items="@load(vm.array)">
<div>Test Label1</div>
</forEach>
</div>
</forEach>
</div>
</div>
</zk>
Test Result
Memory Consumption
Response Time
Summary
ZK 8 has both memory and response improvements, it is faster and lighter than ZK 7. If using the ZK 8 new feature - Shadow Elements, the memory consumption is approximately one-third lighter than ZK 7 for 100 to 1500 concurrent users. Regarding the response time, ZK 8 is approximately 6 to 12 times faster than the old version. We hope you will like the speed enhancement of ZK 8!
Enhancement Notes
ALL editions enhancement 1. Re-implement children binding mechanism. 2. Use a direct method invoking instead of java reflection for component to apply properties. 3. Use a lazy initialization of Java Object creation to reduce the memory footprint. 4. Use StringBuilder instead of StringBuffer for component rendering. 5. Use new string escape implementation. 6. Use java.util.concurrent framework instead of synchronised keyword.
EE version MVVM 1. Use a merge algorithm to reduce the MVVM tracking nodes. 2. Speed up Bind EL expression resolving.
Shadow Element 1. More lightweight and more efficient to support a collection data binding. 2. Auto-release the memory once it doesn't contain a dynamical data attributes.
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |