Derek Scherger wrote:

> Hi folks, I've just recently downloaded ECS and started trying to use it
> as a cleaner alternative to what is going to be some really ugly JSP
> code, and my first impressions are very good. It is so much cleaner than
> JAVA embedded in HTML (JSP) or HTML embedded in JAVA
> (out.println("<TAG>") that I'm all but sold.
>
> Here's the catch...
>
> We're generally quite concerned with the performance of our applications
> and new technologies don't generally get the nod unless they compare
> reasonably well with old ones. At the moment, I'm testing ECS against
> some functionally similar JSP code to generate a somewhat large table
> (1000 rows by 10 columns) and JSP is about 10x faster, which is going to
> make ECS a really hard sell.
>

Sounds about right.  htmlKona is about 2x to 3x faster then ECS.  I would expect
jsp to be even faster as it doesn't generate any html from objects, they are
always just strings.  And doing a println("<sometag here>") is going to be faster
then calling output or to string on an ecs object.  I would welcome in
performance improvements.

>
> First thoughts on this problem were that the number of objects being
> instantiated for this table, on the order of 10,000 or so, was likely a
> big part of the problem.

modern vm's do this really well.

> However, a simple test shows that the output or
> actual generation of the HTML takes far longer than instantiating the
> required ECS objects, something like 10x longer generating than
> instantiating.
>

Sounds about right modern vm's handle object creation and distruction realitivly
well.

>
> So, first question: does this sound reasonable?
>
> And, second question: how can I improve the HTML generation time by a
> factor of 10 or so?
>

Some things to check that will impact performance are filtering & prettyprinting,
they should be turned off. I don't think you will be able to get a 10x
improvment.  The ecs core is pretty solid at this point and there aren't any
glaringly obvious performance bottlenecks. You might get lucky and improve the
speed by 2x or 3x.  If you are able to get any performance increases from the
core, send me a patch and I will happily add them.

>
> I haven't dug very deep into the code yet to see what's going on and I'm
> hoping someone can shed some light on this. Here's my test program and
> results, I hope they help!
>
> import java.io.*;
>
> import org.apache.ecs.*;
> import org.apache.ecs.html.*;
>
> public class newTimer {
>
>     public static void main(String args[]) {
>         long start;
>         long end;
>
>         start = System.currentTimeMillis();
>         System.out.println("Start: " + start);
>
>         int count = 1000000;
>
>         for (int i=0; i<count; i++) {
>             String s = new String("foo");
>         }
>
>         end = System.currentTimeMillis();
>         System.out.println("End:   " + end);
>
>         System.out.println("Created " + count + " Strings in " + (end - start)
> + "ms");
>
>         Html page = new Html();
>         Head head = new Head();
>         Body body = new Body();
>         page.addElement(head);
>         page.addElement(body);
>
>         Table table = new Table();
>         body.addElement(table);
>
>         start = System.currentTimeMillis();
>         System.out.println("Start: " + start);
>
>         for (int i=0; i<1000; i++) {
>             TR row = new TR();
>             table.addElement(row);
>
>             for (int j=0; j<10; j++) {
>                 row.addElement(new TD("" + i + "," + j));
>             }
>         }
>
>         end = System.currentTimeMillis();
>         System.out.println("End:   " + end);
>
>         System.out.println("Created 1000 row table in " + (end - start) +
> "ms");
>
>         try {
>             FileOutputStream file = new FileOutputStream("foo.html");
>
>             start = System.currentTimeMillis();
>             System.out.println("Start: " + start);
>
>             page.output(file);
>
>             end = System.currentTimeMillis();
>             System.out.println("End:   " + end);
>
>             System.out.println("Generated HTML in " + (end - start) + "ms");
>             file.close();
>         }
>         catch (Exception e) {
>             e.printStackTrace();
>         }
>
>
>     }
> }
>
> voodoo$ javac newTimer.java
> voodoo$ java newTimer
> Start: 953877468186
> End:   953877474677
> Created 1000000 Strings in 6491ms
> Start: 953877474730
> End:   953877480225
> Created 1000 row table in 5495ms
> Start: 953877480226
> End:   953877536715
> Generated HTML in 56489ms
> voodoo$
>
> I realize that my timing technique is rather crude but the results are
> consistent.

You should buffer you output stream.

>
>
> The first timing result (6.491 seconds) is a simple benchmark creating
> new Strings, so you might be able to compare numbers from different
> machines. These are from the kaffe-1.0.b4-2 JVM running under Linux
> (RedHat 6.0) on an idle 450 MHz PIII.

The solaris exact vm screams on this stuff.  It will take an ecs document that
contains somewhere in the neighborhood of 800,000 ecs objects and spit it out in
approx. 8 to 12 seconds. ( don't have exact numbers been awhile since i
benchmarked it )

-stephan



--
------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to