$10K coding deathmatch

Paul Seamons paul at seamons.com
Fri Nov 3 11:34:22 MST 2006


If you are comparing language execution speed {
  You may want to try the original perl line I submitted in order to get a 
more  effective comparison (or perhaps my original one but with 
shortcircuiting).  Alan's fixes certainly speed things up - but the "-a" 
invokes lower level parsing of the STDIN (basically a cheat) and the "-p" 
allows for not calling the standard print library which also may end up 
bypassing code which might be a speed reduction.

Actually after testing I see that I am just plain wrong.  The command line 
switches only serve to 
rewrite the code as the following shows:

[paul at www1 lib]$ perl -MO=Deparse -e '$t=1'
$t = 1;
-e syntax OK

[paul at www1 lib]$ perl -MO=Deparse -ape '$t=1'
LINE: while (defined($_ = <ARGV>)) {
    our(@F) = split(" ", $_, 0);
    $t = 1;
}
continue {
    print $_;
}
-e syntax OK

The "-ap" switches really do just put wrappers around the existing code.

Either way - in these cases, it may be good for Josh to specify a little more 
if the solutions must perform the reading of the input and the writing of 
output using standard language functions or libraries - not commandline 
switches.
 
} else if you just want to test raw speed of the fastest example {
  Use Alan's fixes.  They are awesome shortcuts and speedups.

}

Paul



More information about the PLUG mailing list