  | |  | SilverStream delays | SilverStream delays 2003-09-10 - By Tom Eastmond
I am testing SimpleXSLTServlet on a SilverStream 3.75 application server. The first time the servlet is run it takes nearly 18 minutes (not seconds). After the first run, execution times are less then half a second. I don't see this delay running the same servlet in Tomcat 4.1. Below I've included the code I'm using - does anyone know why this could be taking so long?
TIA,
Tom
long start = System.currentTimeMillis();
// The servlet returns HTML.
res.setContentType("text/html; charset=UTF-8");
// Output goes in the response stream.
PrintWriter out = res.getWriter();
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get the XML input document and the stylesheet.
Source xmlSource = new StreamSource(new URL("file", "", "..//Resources//StyleSheets//birds.xml").openStream());
Source xslSource = new StreamSource(new URL("file", "", "..//Resources//StyleSheets//birds.xsl").openStream());
// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new StreamResult(out));
}
catch (Exception e)
{
out.write(e.getMessage());
e.printStackTrace(out);
}
out.close();
System.out.println("Time elapsed: " + (System.currentTimeMillis() - start)); //typical output on first run - 1118617
return; //afterwards - 400-500
<html>
<head> <meta http-equiv=Content-Type content="text/html; charset=us-ascii"> <meta name=Generator content="Microsoft Word 10 (filtered)">
<style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} span.EmailStyle17 {font-family:Arial; color:windowtext;} @(protected) Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {page:Section1;} --> </style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>I am testing SimpleXSLTServlet on a SilverStream 3.75 application server. The first time the servlet is run it takes nearly 18 minutes (not seconds). After the first run, execution times are less then half a second. I don’t see this delay running the same servlet in Tomcat 4.1. Below I& #8217;ve included the code I’m using – does anyone know why this could be taking so long?</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>TIA,</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'>Tom</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> long start = System.currentTimeMillis();</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>// The servlet returns HTML.</span>< /font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> res.setContentType("text/html; charset=UTF-8"); </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> // Output goes in the response stream.</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> PrintWriter out = res.getWriter();</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> try</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> { </span>< /font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> TransformerFactory tFactory = TransformerFactory.newInstance();</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> / / Get the XML input document and the stylesheet.</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> Source xmlSource = new StreamSource(new URL("file", "", "..//Resources//StyleSheets//birds.xml").openStream());</span></font> </p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> Source xslSource = new StreamSource(new URL("file", "", "..//Resources//StyleSheets//birds.xsl").openStream());</span></font> </p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> / / Generate the transformer.</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> Transformer transformer = tFactory.newTransformer(xslSource);</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> / / Perform the transformation, sending the output to the response.</span></font>< /p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> transformer.transform(xmlSource, new StreamResult(out));</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> }</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> catch (Exception e)</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> {</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> out.write(e.getMessage());</span>< /font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> e.printStackTrace(out); </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> }</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> out.close();</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> System.out.println("Time elapsed: " + (System.currentTimeMillis() - start)); //typical output on first run - 1118617</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'> return; //afterwards - 400-500</span></font></p>
</div>
</body>
</html>
|
|
|