← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:15 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/String/RewritePrefix.pm
StatementsExecuted 50 statements in 425µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21121µs25µsString::RewritePrefix::::_new_rewriterString::RewritePrefix::_new_rewriter
21116µs16µsString::RewritePrefix::::__ANON__[:57]String::RewritePrefix::__ANON__[:57]
21114µs55µsString::RewritePrefix::::rewriteString::RewritePrefix::rewrite
11112µs253µsString::RewritePrefix::::BEGIN@11String::RewritePrefix::BEGIN@11
11110µs20µsMooseX::Storage::::BEGIN@1 MooseX::Storage::BEGIN@1
1116µs9µsMooseX::Storage::::BEGIN@2 MooseX::Storage::BEGIN@2
2114µs4µsString::RewritePrefix::::CORE:sortString::RewritePrefix::CORE:sort (opcode)
1113µs3µsString::RewritePrefix::::BEGIN@4String::RewritePrefix::BEGIN@4
1113µs3µsString::RewritePrefix::::BEGIN@7String::RewritePrefix::BEGIN@7
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1223µs231µs
# spent 20µs (10+11) within MooseX::Storage::BEGIN@1 which was called: # once (10µs+11µs) by MooseX::Storage::BEGIN@13 at line 1
use strict;
# spent 20µs making 1 call to MooseX::Storage::BEGIN@1 # spent 10µs making 1 call to strict::import
2234µs212µs
# spent 9µs (6+3) within MooseX::Storage::BEGIN@2 which was called: # once (6µs+3µs) by MooseX::Storage::BEGIN@13 at line 2
use warnings;
# spent 9µs making 1 call to MooseX::Storage::BEGIN@2 # spent 3µs making 1 call to warnings::import
3package String::RewritePrefix;
4
# spent 3µs within String::RewritePrefix::BEGIN@4 which was called: # once (3µs+0s) by MooseX::Storage::BEGIN@13 at line 6
BEGIN {
514µs $String::RewritePrefix::VERSION = '0.006';
6114µs13µs}
# spent 3µs making 1 call to String::RewritePrefix::BEGIN@4
7232µs13µs
# spent 3µs within String::RewritePrefix::BEGIN@7 which was called: # once (3µs+0s) by MooseX::Storage::BEGIN@13 at line 7
use Carp ();
# spent 3µs making 1 call to String::RewritePrefix::BEGIN@7
8# ABSTRACT: rewrite strings based on a set of known prefixes
9
10# 0.972 allows \'method_name' form -- rjbs, 2010-10-25
111200ns
# spent 253µs (12+241) within String::RewritePrefix::BEGIN@11 which was called: # once (12µs+241µs) by MooseX::Storage::BEGIN@13 at line 13
use Sub::Exporter 0.972 -setup => {
12 exports => [ rewrite => \'_new_rewriter' ],
132266µs3494µs};
# spent 253µs making 1 call to String::RewritePrefix::BEGIN@11 # spent 233µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] # spent 8µs making 1 call to UNIVERSAL::VERSION
14
15
16
# spent 55µs (14+42) within String::RewritePrefix::rewrite which was called 2 times, avg 28µs/call: # 2 times (14µs+42µs) by MooseX::Storage::_rewrite_role_name at line 31 of MooseX/Storage.pm, avg 28µs/call
sub rewrite {
1721µs my ($self, $arg, @rest) = @_;
1828µs442µs return $self->_new_rewriter(rewrite => { prefixes => $arg })->(@rest);
# spent 25µs making 2 calls to String::RewritePrefix::_new_rewriter, avg 13µs/call # spent 16µs making 2 calls to String::RewritePrefix::__ANON__[String/RewritePrefix.pm:57], avg 8µs/call
19}
20
21
# spent 25µs (21+4) within String::RewritePrefix::_new_rewriter which was called 2 times, avg 13µs/call: # 2 times (21µs+4µs) by String::RewritePrefix::rewrite at line 18, avg 13µs/call
sub _new_rewriter {
222700ns my ($self, $name, $arg) = @_;
232700ns my $rewrites = $arg->{prefixes} || {};
24
252100ns my @rewrites;
26212µs24µs for my $prefix (sort { length $b <=> length $a } keys %$rewrites) {
# spent 4µs making 2 calls to String::RewritePrefix::CORE:sort, avg 2µs/call
2743µs push @rewrites, ($prefix, $rewrites->{$prefix});
28 }
29
30
# spent 16µs within String::RewritePrefix::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/String/RewritePrefix.pm:57] which was called 2 times, avg 8µs/call: # 2 times (16µs+0s) by String::RewritePrefix::rewrite at line 18, avg 8µs/call
return sub {
312100ns my @result;
32
332500ns Carp::cluck("string rewriter invoked in void context")
34 unless defined wantarray;
35
362600ns Carp::croak("attempt to rewrite multiple strings outside of list context")
37 if @_ > 1 and ! wantarray;
38
3922µs STRING: for my $str (@_) {
4021µs for (my $i = 0; $i < @rewrites; $i += 2) {
4131µs if (index($str, $rewrites[$i]) == 0) {
422800ns if (ref $rewrites[$i+1]) {
43 my $rest = substr $str, length($rewrites[$i]);
44 my $str = $rewrites[ $i+1 ]->($rest);
45 push @result, (defined $str ? $str : '') . $rest;
46 } else {
4723µs push @result, $rewrites[$i+1] . substr $str, length($rewrites[$i]);
48 }
4921µs next STRING;
50 }
51 }
52
53 push @result, $str;
54 }
55
5625µs return wantarray ? @result : $result[0];
57210µs };
58}
59
6012µs1;
61
62__END__
 
# spent 4µs within String::RewritePrefix::CORE:sort which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by String::RewritePrefix::_new_rewriter at line 26, avg 2µs/call
sub String::RewritePrefix::CORE:sort; # opcode