JSP - Scriptlet performance with high amount of HTML code
<p>I have a JSP contains high amount of HTML code. There are many inner divs, spans and h2 tags. The HTML code is generated by scriplets using some for loops.</p>

<p>I measure the scriptlet process by using the following :</p>

<pre><code>   &lt;% long time = System.currentTimeMillis(); %&gt;
     // here is the entire page data
   &lt;% System.out.println("Time : " + (System.currentTimeMillis()-time)); %&gt;
</code></pre>

<p>According to this measurement, the process time is 300-350 msecs.</p>

<p>To spot the parts that make the delay, I did something like that :</p>

<pre><code>    &lt;% long time = System.currentTimeMillis(); %&gt;
         // Some HTML Blocks
    &lt;% System.out.println("Time1 : " + (System.currentTimeMillis()-time)); %&gt;
         // Another HTML Blocks
    &lt;% System.out.println("Time2 : " + (System.currentTimeMillis()-time)); %&gt;
</code></pre>

<p>However, I realised that sometimes even if I do the following, even there is no html block between printlns, the time value is still changes !</p>

<pre><code>   &lt;% long time = System.currentTimeMillis(); %&gt;
             // Some Blocks
   &lt;% System.out.println("Time1 : " + (System.currentTimeMillis()-time)); %&gt;
   &lt;% System.out.println("Time2 : " + (System.currentTimeMillis()-time)); %&gt;
</code></pre>

<p>Output is : </p>

<pre><code>Time1 : 65
Time2 : 208
</code></pre>

<p>So what is the thing that slow down my page ? How can I detect the point?</p>

<p>Do the Scriptlets have performance weakness for processing heavy HTML codes?</p>

<p>----- UPDATE ------</p>

<p><a href="https://i.stack.imgur.com/p1jT0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p1jT0.png" alt="enter image description here"></a></p>

<p>Here is the output : </p>

<pre><code> first : 0
 Sec : 0
 thr : 0
 fr : 180
 Total : 180
</code></pre>

<p>There is nothing between thr and fr but fr value is 180 !</p>