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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.