The goal is to measure the client-side perfomance of JS script block executions for PrimeFaces p:inputText / p:selectOneMenu. There is no backend logic. For perfomance test, an editable p:dataTable with inputs / selects components within the table cells is used. The table has 25 rows and 16 columns, that means 25 * 16 = 400 cells. Every cell contains either an input or a select component. There are 6 test cases, depending on component's combinations.
- An input can be either an JSF standard h:inputText (without any JS script block) or PrimeFaces' p:inputText (with JS script block execution).
- A select can be either a JSF standard h:selectOneMenu (without any JS script block) or PrimeFaces' p:selectOneMenu (with JS script block execution).
The following function is used to measure and output the time after the current response has been arrived until the window onload event is fired (everything were loaded and executed).
<script type="text/javascript">
$(window).load(function () {
setTimeout(function () {
window.performance = window.performance ||
window.mozPerformance ||
window.msPerformance ||
window.webkitPerformance || {};
var timing = performance.timing || {};
var loadTime = timing.loadEventEnd - timing.responseEnd;
console.log(loadTime);
$("#timeOutput").html("Load Time (ms) = " + loadTime);
}, 0);
});
</script>
JavaScript is single-threaded, so let's see how sequential script block executions can slow down displaying a web page.
Open your console / terminal window and clone the repository with
git clone git://github.com/ova2/perf-test.git
The demo web application is prepared to run with Jetty 8 server. To run it with JSF Mojarra implementation, type in the console / terminal window
mvn jetty:run
To run it with JSF MyFaces implementation, type
mvn jetty:run -Pmyfaces
This starts Jetty server and the demo app is available under the following URL in a web browser
http://localhost:8080/perf-test/
Jetty will continue to run until you stop it with a Ctrl+C in the console / terminal window where it is running. Alternative, you can compile the project
mvn clean package
and deploy the WAR file on every JEE 6 compliant server of your choice.