You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Chamas <jo...@chamas.com> on 2000/12/18 00:53:29 UTC

RFC: Hello World 2000 Benchmark

Hey,

I'd like some comments on the Hello World 2000 benchmark that 
I am creating.  One of the great failings of the Hello World
benchmark is that it doesn't address the runtime execution 
of various web application environments.  

Perl is oft stated to provide better runtime execution for web apps 
than other languages like Java or PHP, but I have never seen anything 
to back this up, and I would like to see how things stack up in a 
benchmark.

The first of these runtime benchmarks is geared towards templating
or embedded environments like ASP,PHP,Embperl,JSP,Mason ...  the
Hello World 2000 benchmark below has these characteristics:

  2+ levels of code layering
  1 rand() value per request
  6 for loops executed
  20 additions (float & integer) 
  10 lval assignments
  200 variables inline
  202+ chuncks of static html rendered
  Over 2900 byte template to parse
  Over 29K html output

Its named Hello World 2000 because it spits out 2000 Hello Worlds :)
This is a heavy template, its supposed to be to reasonably test
an environment.  

The next benchmark I'd like to set up might be called the 
Hello Database 10, which would likely fire off 1 insert, 8 selects, 
and 1 delete to a MySQL database.  This test would be geared 
towards looking at web->database connectivity speed, & the relevant i/o 
for the various languages & environments.  It would differentiate
less between the various web apps, and more between the languages
and databse drivers they run.

A heavy benchmark might be one that fuses the Hello World 2000
and the Hello Database 10 benchmarks together in one execution.

-- Josh

## Apache::ASP reference for Hello World 2000 benchmark

<html><head><title>Hello World 2000</title></head><body>
<% 
my $rand = rand();
for my $i (1..5) { 
 for my $j (1..2) { 
  my $var = $i+$j+$rand; 
  %>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <%=$var%> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World <br/>
  <% 
 }
} 
%>
</body></html>

Float vs Int? [ WAS: Re: RFC: Hello World 2000 Benchmark ]

Posted by Joshua Chamas <jo...@chamas.com>.
Joshua Chamas wrote:
> 
> Hey,
> 
> I'd like some comments on the Hello World 2000 benchmark that
> I am creating.  One of the great failings of the Hello World
> benchmark is that it doesn't address the runtime execution
> of various web application environments.
> 

It seems that the assumption of a perl type rand() float was 
wrong cross language... perl has it, but PHP doesn't, to get a 
rand() float in PHP, one seems to need to:

  $rand = rand(0,1000) / 1000;

So I wonder, if this rand token that gets inserted into the
HTML like 

  $var = $i+$j+$rand; ?>
  <? echo($var) ?> Hello World Hello World Hello World 

should be an int or a float?  Personally, I can't remember
the last time I needed floating point logic in an HTML template,
so it seems that I maybe I should stick with ints.  Note that I 
believe perl handles floats better than Java or PHP, so this 
decision affects the results of the benchmark.  I think floats
should be part of a general language test, but this one?

Your comments would be appreciated.

--Josh

Re: RFC: Hello World 2000 Benchmark

Posted by Joshua Chamas <jo...@chamas.com>.
Perrin Harkins wrote:
> 
> This sounds great, but the code snippet you included makes it look like
> the rand() value will have an effect on the number of bytes returned.
> This is probably not a good idea, since that would allow many other
> factors to affect the results.  I suggest making sure that the benchmark
> returns identical results on every platform and every execution.
> 

You are right, further complicated that every language handles
rand() a bit differently... what I have now is a 3 digit float 
between 0.000 and 1.000, and if this is to be an int to avoid float 
calculations, then perhaps 0 - 1000

<% 
my $rand = int(rand() * 1000) / 1000;
for my $i (1..5) { 
 for my $j (1..2) { 
  my $var = $i+$j+$rand; 
...

> That also sounds cool.  If possible, please try to write in such a way
> that people running on other databases can easily customize it to test
> their environment.
> 

Will do my best.

> I volunteer to review code and offer tuning tips for the platforms I'm
> familiar with.
> 

Thanks.  

Josh

_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: RFC: Hello World 2000 Benchmark

Posted by Perrin Harkins <pe...@primenet.com>.
Joshua Chamas wrote:
> The first of these runtime benchmarks is geared towards templating
> or embedded environments like ASP,PHP,Embperl,JSP,Mason ...  the
> Hello World 2000 benchmark below has these characteristics:
> 
>   2+ levels of code layering
>   1 rand() value per request
>   6 for loops executed
>   20 additions (float & integer)
>   10 lval assignments
>   200 variables inline
>   202+ chuncks of static html rendered
>   Over 2900 byte template to parse
>   Over 29K html output

This sounds great, but the code snippet you included makes it look like
the rand() value will have an effect on the number of bytes returned. 
This is probably not a good idea, since that would allow many other
factors to affect the results.  I suggest making sure that the benchmark
returns identical results on every platform and every execution.

> The next benchmark I'd like to set up might be called the
> Hello Database 10, which would likely fire off 1 insert, 8 selects,
> and 1 delete to a MySQL database.  This test would be geared
> towards looking at web->database connectivity speed, & the relevant i/o
> for the various languages & environments.  It would differentiate
> less between the various web apps, and more between the languages
> and databse drivers they run.

That also sounds cool.  If possible, please try to write in such a way
that people running on other databases can easily customize it to test
their environment.

Of course ultimately coding styles usually affect performance more than
raw platform speed.  PHP leans toward in-line code, Perl leans toward
modules and subroutine calls, and Java leans towards lots of objects and
more abstraction.  However, you can use any of these styles on any of
these platforms so at least this will tell you if you're starting out
even on your tool of choice.

I volunteer to review code and offer tuning tips for the platforms I'm
familiar with.

- Perrin

Re: RFC: Hello World 2000 Benchmark

Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 18 Dec 2000, Joshua Chamas wrote:
> The rand() is only in there to prevent a language compiler 
> from rendering the whole thing static if it were able to 
> guess that all of the variables would be knowable by 
> unwinding the for loops.

Instead of using a random number, why don't you pas in the number as a
query arg?  Then you can test the query parsing of each system as well.

- Perrin


Re: RFC: Hello World 2000 Benchmark

Posted by Joshua Chamas <jo...@chamas.com>.
Gunther Birznieks wrote:
> 
> And a partridge in a pear tree.... :) Sorry... it's just stupid xmas carols.
> 

You've got the spirit. :)

> Anyway, if you are splitting out the DB side for later then why not do the
> same for language features and template features? Here they are both rolled
> into one test it seems.
> 

I tried to include language features that were relevant to 
a template, which is definately additions and then variable
substitutions.  

The rand() is only in there to prevent a language compiler 
from rendering the whole thing static if it were able to 
guess that all of the variables would be knowable by 
unwinding the for loops.  A regular template, building
HTML from a database, would not be something a compiler 
could optimize in such a fashion.

> I don't think all applications or handlers actually use templates at all.
> Although I guess it's fair to say that languages like PHP are forced to use
> templates.
> 

Yes, I'm not sure its even relevant to construct the equivalent
mod_perl handler & registry tests for this because it is a 
template benchmark.

> Also I suspect the template features (which seem like a lot of overhead)
> will override any difference in the adds and randomizing speed.

We'll soon see!  Did you have an opinion on floats or not?
You seem to have a good feel for these environments.

-- Josh

Re: RFC: Hello World 2000 Benchmark

Posted by Gunther Birznieks <gu...@extropia.com>.
At 03:53 PM 12/17/00 -0800, Joshua Chamas wrote:
>Hey,
>
>
>   2+ levels of code layering
>   1 rand() value per request
>   6 for loops executed
>   20 additions (float & integer)
>   10 lval assignments
>   200 variables inline
>   202+ chuncks of static html rendered
>   Over 2900 byte template to parse
>   Over 29K html output

And a partridge in a pear tree.... :) Sorry... it's just stupid xmas carols.

Anyway, if you are splitting out the DB side for later then why not do the 
same for language features and template features? Here they are both rolled 
into one test it seems.

I don't think all applications or handlers actually use templates at all. 
Although I guess it's fair to say that languages like PHP are forced to use 
templates.

Also I suspect the template features (which seem like a lot of overhead) 
will override any difference in the adds and randomizing speed.