Hi rhesa, thanks for your comments!
<quote>Thinking one additional method call would ruin performance is, IMHO, misguided</quote>
Yes, I agree with that... until I found some inline methods in Tie::File source code with comments like "inlining read_record() would make this loop five times faster"
I've already done a Benchmark and found that in fact my inherited version in sensible faster than the original Tie::File (I suppose that it is because lines are grouped into records and the indexing, etc... is faster). The benchmark code and results are shown below.
<quote>You break inheritance with the check on the object's class name: with your code, it's now impossible to subclass that particular method and benefit from its features</quote>
Sorry, I don't understand this point
Thanks!
citromatik
Benchmark
Code
use strict; use warnings; use Benchmark; use myTie::File::GFF; use myTie::File; use Tie::File; my $f = shift @ARGV; tie my @arr1, 'myTie::File', $f; tie my @arr2, 'myTie::File::GFF', $f; tie my @arr3, 'Tie::File',$f; Benchmark::cmpthese (100, { 'call_same_module' => sub {my $cont=0; for (@arr1){$cont +++;}}, 'inherited' => sub {my $cont=0; for (@arr2){$cont++;}}, 'orig_tiefile' => sub {my $cont=0; for (@arr3){$cont++ +}} } );
Benchmark result
Rate call_same_module orig_tiefile inhe +rited call_same_module 100.0/s -- -8% + -71% orig_tiefile 109/s 9% -- + -68% inherited 345/s 245% 217% + --
citromatik
In reply to Re^2: RFC:Hacking Tie::File to read complex data
by citromatik
in thread RFC:Hacking Tie::File to read complex data
by citromatik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |