Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Re: Re: RFC CGI.pm refactoring

by little (Curate)
on Feb 15, 2002 at 15:12 UTC ( [id://145690]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: RFC CGI.pm refactoring
in thread RFC CGI.pm refactoring

Would you please benchmark this again?
use Benchmark; use CGI qw/:cgi /; use CGI::Simple; $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; $q = new CGI; $s = new CGI::Simple; timethese(250000, {'CGI' =>'$q->param("baz")', 'Simple' => '$s->param( +"baz")'});
Sorry, but comparing fully blown CGI while forcing it to load all is quitely unfair in this case while CGI.pm has an option to run in a different manner.

Have a nice day
All decision is left to your taste

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: RFC CGI.pm refactoring
by Masem (Monsignor) on Feb 15, 2002 at 15:18 UTC
    And even then, with this test, while it's fair in how fast it accesses, the real concern would be the speed in breaking down the query string. I propose a better test would be :
    use Benchmark; use CGI qw/:cgi /; use CGI::Simple; $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; timethese(250000, {'CGI' => '$q = new CGI; $q->param("baz")', 'Simple' => '$s = new CGI::Simple; $s->param( +"baz")'});

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    "I can see my house from here!"
    It's not what you know, but knowing how to find it if you don't know that's important

      The qw/:cgi/ part is wrong as noted above but as you note there are a number of factors to CGI speed. Have a look at CGI::Simple vs CGI.pm - Is twice as fast good enough? for a much more thorough analysis.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Re: Re: Re: Re: RFC CGI.pm refactoring
by tachyon (Chancellor) on Feb 15, 2002 at 15:48 UTC

    Actually you completely fail to understand how CGI.pm works. When you use CGI; you import 0 methods. The methods are available via the OO interface and compiled on demand. When you use CGI qw/:cgi/; you import and compile the basic cgi methods (which you would otherwise not do with a straight use CGI;). As we are making OO calls this is a complete waste of time. Running your example you can see that the time remains essentially the same as expected (loading the extra methods once (with the use CGI qw/:cgi/;) adds about a second to the load time but this is a once off price and we are then looping.

    use Benchmark; use CGI qw/:cgi /; use CGI::Simple; $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; $q = new CGI; $s = new CGI::Simple; timethese(250000, {'CGI' =>'$q->param("baz")', 'Simple' => '$s->param( +"baz")'}); __DATA__ Benchmark: timing 250000 iterations of CGI, Simple... CGI: 29 wallclock secs (27.53 usr + 0.00 sys = 27.53 CPU) @ 90 +81.00/s (n=250000) Simple: 10 wallclock secs ( 9.99 usr + 0.00 sys = 9.99 CPU) @ + 25025.03/s (n=250000)

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://145690]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found