>>>>> "CO" == Chas Owens <chas.ow...@gmail.com> writes:

  CO> You may think there is more code in the while loop version, but really
  CO> it there is less.  File::Slurp is a pure Perl module.  That means that
  CO> whatever loop it is using to get the data must happen in Perl.  Then
  CO> you copy that data to an array, then the hash slice has to iterate
  CO> over the array.  You have three loops (two of which are in C), but the
  CO> while loop has one.  Using File::Slurp to get an array is slower than
  CO> dumping the file handle into an array.  File::Slurp may be faster than
  CO> a straight slurp when slurping to a scalar, but I doubt it.
  CO> File::Slurp's only real advantage is that

you haven't seen all the deeper benchmarks. it is faster than most any
other slurp method and handles all errors correctly and with the style
of your choice. also returning an array ref is faster still but i didn't
want to overload the newbie with that as well. in the git repo there is
a newer benchmark script which is more informative and allows for
multiple size tests as well. don't go off on speed things when you don't
have all the facts. :)

i am not going to debate speed issues of slurp here as it is the wrong
forum.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to