On Mon, Oct 27, 2008 at 21:35, Tim Bunce <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 27, 2008 at 03:03:02AM -0700, [EMAIL PROTECTED] wrote:
>>
>> Log:
>> Add Devel::NYTProf::Data::Raw module
>>
>> This provides an interface for reading the raw profile data files.
>> I just found this handy for understanding the file format and debugging
>> it.  It also opens up ways for creating alternative ways to summarize the
>> data from Perl.
>
> Thanks Gisle!
>
> I'd envisaged this being implemented as a SAX provider. Any chance you
> could rework it along those lines?

What do you mean by SAX provider?  You want it to actually be
compatible with XML::SAX and call out to the XML::SAX::Base interface?

I would have preferred an iterator interface instead, but I did not
see an easy way to get there, so I started with a simple callback
scheme instead.

My preference would be:

    my $next_chunk = nytprof_out_iter("nytprof.out");
    while (my($tag, @args) = $next_chunk->()) {
          # ....
    }

>> +lib/Devel/NYTProf/Data/Raw.pm
>
> I'd rather it was called Devel::NYTProf::ReadStream.pm as
> Devel::NYTProf::Data::Raw doesn't convey much and the extra nesting
> under Data is potentially confusing as it's not related to the ::Data
> module (which itself isn't a great name).

I think we can wait with revising the name until the interface has
found its form.  To me the ::Data part means the 'nytprof.out' file
format basically, so in that way I found the name logical.  I started
out with a class method on the ::Data class, but it did feel right so
I decided to just create a submodule instead.

>
>> +    if (cb) {
>> +        PUSHMARK(SP);
>> +     if (cb_seq) XPUSHs(sv_2mortal(newSViv(input_chunk_seqn)));
>> +     XPUSHs(sv_2mortal(newSVpvs("VERSION")));
>> +     XPUSHs(sv_2mortal(newSViv(file_major)));
>> +     XPUSHs(sv_2mortal(newSViv(file_minor)));
>> +     PUTBACK;
>> +     call_sv(cb, G_DISCARD);
>> +    }
>
> Isn't this approach going to accumulate lots of unfreed mortal temps?

Right.  I only tried this on small toy samples.

> Rather than going the ENTER/sv_2mortal/LEAVE route I was thinking
> of reusing a number of pre-allocated SVs. Would be much faster.

The semantics could be slightly weird for users that grab references
to the arguments passed in, but that price might well be worth it.
The tags themselves should just be the same (constant) SV passed in to
each call and then deallocated at the end of the loop.

>
>> +                 if (cb_seq) XPUSHs(sv_2mortal(newSViv(input_chunk_seqn)));
>
> I think we could reuse $. (or some global of our own) for input_chunk_seqn.

Good idea.  It's anyway just a hack I wanted for the test suite so the
test would fail if somebody added branches to the big switch statement
without adding a corresponding callback.  I could also just undocument
it.

--Gisle

--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to