← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/Text/Tabs.pm
StatementsExecuted 15 statements in 481µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs57µsText::Tabs::::BEGIN@9Text::Tabs::BEGIN@9
1119µs9µsText::Tabs::::BEGIN@15Text::Tabs::BEGIN@15
1116µs17µsText::Tabs::::BEGIN@13Text::Tabs::BEGIN@13
1113µs3µsText::Tabs::::BEGIN@17Text::Tabs::BEGIN@17
1112µs2µsText::Tabs::::CORE:qrText::Tabs::CORE:qr (opcode)
0000s0sText::Tabs::::_xlenText::Tabs::_xlen
0000s0sText::Tabs::::_xposText::Tabs::_xpos
0000s0sText::Tabs::::expandText::Tabs::expand
0000s0sText::Tabs::::unexpandText::Tabs::unexpand
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Text::Tabs;
3
41800nsrequire Exporter;
5
616µs@ISA = (Exporter);
71800ns@EXPORT = qw(expand unexpand $tabstop);
8
9229µs2102µs
# spent 57µs (12+45) within Text::Tabs::BEGIN@9 which was called: # once (12µs+45µs) by Text::Wrap::BEGIN@35 at line 9
use vars qw($VERSION $SUBVERSION $tabstop $debug);
# spent 57µs making 1 call to Text::Tabs::BEGIN@9 # spent 45µs making 1 call to vars::import
101200ns$VERSION = 2012.0818;
111100ns$SUBVERSION = 'modern';
12
13219µs227µs
# spent 17µs (6+10) within Text::Tabs::BEGIN@13 which was called: # once (6µs+10µs) by Text::Wrap::BEGIN@35 at line 13
use strict;
# spent 17µs making 1 call to Text::Tabs::BEGIN@13 # spent 10µs making 1 call to strict::import
14
15240µs19µs
# spent 9µs within Text::Tabs::BEGIN@15 which was called: # once (9µs+0s) by Text::Wrap::BEGIN@35 at line 15
use 5.010_000;
# spent 9µs making 1 call to Text::Tabs::BEGIN@15
16
17
# spent 3µs within Text::Tabs::BEGIN@17 which was called: # once (3µs+0s) by Text::Wrap::BEGIN@35 at line 20
BEGIN {
181200ns $tabstop = 8;
1913µs $debug = 0;
201370µs13µs}
# spent 3µs making 1 call to Text::Tabs::BEGIN@17
21
2219µs12µsmy $CHUNK = qr/\X/;
# spent 2µs making 1 call to Text::Tabs::CORE:qr
23
24sub _xlen (_) { scalar(() = $_[0] =~ /$CHUNK/g) }
25sub _xpos (_) { _xlen( substr( $_[0], 0, pos($_[0]) ) ) }
26
27sub expand {
28 my @l;
29 my $pad;
30 for ( @_ ) {
31 my $s = '';
32 for (split(/^/m, $_, -1)) {
33 my $offs = 0;
34 s{\t}{
35 # this works on both 5.10 and 5.11
36 $pad = $tabstop - (_xlen(${^PREMATCH}) + $offs) % $tabstop;
37 # this works on 5.11, but fails on 5.10
38 #XXX# $pad = $tabstop - (_xpos() + $offs) % $tabstop;
39 $offs += $pad - 1;
40 " " x $pad;
41 }peg;
42 $s .= $_;
43 }
44 push(@l, $s);
45 }
46 return @l if wantarray;
47 return $l[0];
48}
49
50sub unexpand
51{
52 my (@l) = @_;
53 my @e;
54 my $x;
55 my $line;
56 my @lines;
57 my $lastbit;
58 my $ts_as_space = " " x $tabstop;
59 for $x (@l) {
60 @lines = split("\n", $x, -1);
61 for $line (@lines) {
62 $line = expand($line);
63 @e = split(/(${CHUNK}{$tabstop})/,$line,-1);
64 $lastbit = pop(@e);
65 $lastbit = ''
66 unless defined $lastbit;
67 $lastbit = "\t"
68 if $lastbit eq $ts_as_space;
69 for $_ (@e) {
70 if ($debug) {
71 my $x = $_;
72 $x =~ s/\t/^I\t/gs;
73 print "sub on '$x'\n";
74 }
75 s/ +$/\t/;
76 }
77 $line = join('',@e, $lastbit);
78 }
79 $x = join("\n", @lines);
80 }
81 return @l if wantarray;
82 return $l[0];
83}
84
8514µs1;
86__END__
 
# spent 2µs within Text::Tabs::CORE:qr which was called: # once (2µs+0s) by Text::Wrap::BEGIN@35 at line 22
sub Text::Tabs::CORE:qr; # opcode