my ($start, $end, $cgitime, $simpletime); my $n = 100; $start = time; do{require CGI; undef %INC} for 1..$n; $end = time; $cgitime = $end - $start; print "Loading CGI $n times takes $cgitime seconds\n"; $start = time; do{require CGI::Simple; undef %INC} for 1..$n; $end = time; $simpletime = $end - $start; print "Loading CGI::Simple $n times takes $simpletime seconds\n"; __DATA__ # Standard distro Loading CGI 100 times takes 40 seconds Loading CGI::Simple 100 times takes 29 seconds # With use strict commented out (CGI.pm does not use strict) Loading CGI 100 times takes 39 seconds Loading CGI::Simple 100 times takes 23 seconds #### use Benchmark; use CGI qw/:cgi /; use CGI::Simple; $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; timethese(10000, {'CGI' => '$q = new CGI; $q->param("baz")', 'Simple' => '$s = new CGI::Simple; $s->param("baz")'}); timethese(10000, {'CGI' => '$q = new CGI; $q->param("baz") for 1..10', 'Simple' => '$s = new CGI::Simple; $s->param("baz") for 1..10'}); __DATA__ Benchmark: timing 10000 iterations of CGI, Simple... CGI: 22 wallclock secs (21.70 usr + 0.00 sys = 21.70 CPU) @ 460.83/s (n=10000) Simple: 15 wallclock secs (15.05 usr + 0.00 sys = 15.05 CPU) @ 664.45/s (n=10000) Benchmark: timing 10000 iterations of CGI, Simple... CGI: 32 wallclock secs (31.20 usr + 0.00 sys = 31.20 CPU) @ 320.51/s (n=10000) Simple: 18 wallclock secs (18.57 usr + 0.00 sys = 18.57 CPU) @ 538.50/s (n=10000) #### use Benchmark; $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; $cgi_code = <<'CODE'; %INC = ('Benchmark.pm' => 'C:/Perl/lib/Benchmark.pm'); require CGI; $q = new CGI; $q->param("baz") for 1..10; CODE $simp_code = <<'CODE'; %INC = ('Benchmark.pm' => 'C:/Perl/lib/Benchmark.pm'); require CGI::Simple; $q = new CGI::Simple; $q->param("baz") for 1..10; CODE timethese(100, { 'CGI' => $cgi_code, 'Simple' => $simp_code }); __DATA__ Benchmark: timing 100 iterations of CGI, Simple... CGI: 42 wallclock secs (43.50 usr + 0.00 sys = 43.50 CPU) @ 2.30/s (n=100) Simple: 18 wallclock secs (18.56 usr + 0.00 sys = 18.56 CPU) @ 5.39/s (n=100) #### C:\>type cgi.pl $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; use CGI; $q = new CGI; $q->param("baz") for 1..10; C:\>type cgi-simple.pl $ENV{'QUERY_STRING'} = 'foo=bar&baz=boo'; use CGI::Simple; $q = new CGI::Simple; $q->param("baz") for 1..10; C:\>type test.pl my $start; my $n = 100; $start = time; `perl c:\\cgi.pl` for 1..$n; print "$n iterations using CGI takes ", time-$start, " seconds\n"; $start = time; `perl c:\\cgi-simple.pl` for 1..$n; print "$n iterations using CGI::Simple takes ", time-$start, " seconds\n"; C:\>perl test.pl 100 iterations using CGI takes 73 seconds 100 iterations using CGI::Simple takes 40 seconds C:\>