timbunce / devel-nytprof

Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
http://blog.timbunce.org/tag/nytprof/
67 stars 51 forks source link

call counts for xs subs as methods on objects seem to be off #71

Open wchristian opened 9 years ago

wchristian commented 9 years ago

Here's an archive with an example script, a profile run of it, and the nytprofhtml analysis:

https://dl.dropboxusercontent.com/u/10190786/xs_sub_methods.zip

Of note is that the calls for ->timings each have a count of 10, while the calls for ->sprites each have a count of 1.

Here's the example script:

use strict;
use warnings;

{

    package Object;
    use Moo;

    has timings => ( is => 'rw', lazy => 1, builder => 1 );
    has sprites => ( is => 'rw', default => sub { 0 } );

    sub _build_timings { 1 }
}

run();

sub run {
    my $object = Object->new;

    for ( 1 .. 10 ) {
        my $t = $object->timings;
        $object->timings( $t + 1 );

        my $s = $object->sprites;
        $object->sprites( $s + 1 );
    }

    print $object->timings . " " . $object->sprites;
}
timbunce commented 9 years ago

Does this relate to #72?

Can you create a small test case with Sub::Quote only (either for this or #72) and include it inline here?