%@ page language="java" %>
<%@ page buffer="40kb" %>
<%@ include file="border.inc" %>
JSP performance test: include vs. jsp:include
<%
final long[] timings = new long[6];
final String text1 = "Dit is een include/function test.";
final String text2 = "Dit is een jsp:include test.";
final StringBuffer b = new StringBuffer();
// single function call:
long start = System.currentTimeMillis();
border(b, out, text1);
timings[0] = System.currentTimeMillis() - start;
// multiple function calls:
start = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
border(b, out, text1);
}
timings[1] = System.currentTimeMillis() - start;
// multiple function calls:
start = System.currentTimeMillis();
for (int i = 0; i < 50; i++) {
border(b, out, text1);
}
timings[2] = System.currentTimeMillis() - start;
// single jsp:include call
start = System.currentTimeMillis();
%>
<%
timings[3] = System.currentTimeMillis() - start;
start = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
%>
<%
}
timings[4] = System.currentTimeMillis() - start;
for (int i = 0; i < 50; i++) {
%>
<%
}
timings[5] = System.currentTimeMillis() - start;
String[] explan = {
"single method call:",
"10 method calls:",
"50 method calls:",
"single jsp:include call:",
"10 jsp:include calls:",
"50 jsp:include calls:",
};
out.print("Time in milliseconds:");
out.print("
");
for (int i = 0; i < timings.length; i++) {
out.print("| " + explan[i] + " | " +
timings[i] + " |
");
}
out.print("
");
%>