← Index
NYTProf Performance Profile   « line view »
For split.pl
  Run on Thu Apr 20 02:05:47 2023
Reported on Thu Apr 20 18:31:09 2023

Filename/usr/lib/x86_64-linux-gnu/perl-base/Text/Tabs.pm
StatementsExecuted 39974 statements in 52.6ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
57031133.6ms33.6msText::Tabs::::CORE:match Text::Tabs::CORE:match (opcode)
14311118.3ms51.9msText::Tabs::::expand Text::Tabs::expand
1117µs8µsdiagnostics::::BEGIN@1diagnostics::BEGIN@1
1113µs15µsdiagnostics::::BEGIN@1.1diagnostics::BEGIN@1.1
1112µs2µsText::Tabs::::BEGIN@5 Text::Tabs::BEGIN@5
0000s0sText::Tabs::::unexpand Text::Tabs::unexpand
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1438µs436µs
# spent 8µs (7+1) within diagnostics::BEGIN@1 which was called: # once (7µs+1µs) by diagnostics::BEGIN@197 at line 1 # spent 15µs (3+12) within diagnostics::BEGIN@1.1 which was called: # once (3µs+12µs) by diagnostics::BEGIN@197 at line 1
use strict; use warnings;
# spent 15µs making 1 call to diagnostics::BEGIN@1.1 # spent 12µs making 1 call to warnings::import # spent 8µs making 1 call to diagnostics::BEGIN@1 # spent 1µs making 1 call to strict::import
2
3package Text::Tabs;
4
52275µs12µs
# spent 2µs within Text::Tabs::BEGIN@5 which was called: # once (2µs+0s) by diagnostics::BEGIN@197 at line 5
BEGIN { require Exporter; *import = \&Exporter::import }
# spent 2µs making 1 call to Text::Tabs::BEGIN@5
6
71800nsour @EXPORT = qw( expand unexpand $tabstop );
8
91100nsour $VERSION = '2021.0814';
101100nsour $SUBVERSION = 'modern'; # back-compat vestige
11
121100nsour $tabstop = 8;
13
14
# spent 51.9ms (18.3+33.6) within Text::Tabs::expand which was called 1431 times, avg 36µs/call: # 1431 times (18.3ms+33.6ms) by main::BEGIN@8 at line 378 of diagnostics.pm, avg 36µs/call
sub expand {
151431117µs my @l;
16 my $pad;
171431368µs for ( @_ ) {
181431137µs defined or do { push @l, ''; next };
191431183µs my $s = '';
201431922µs for (split(/^/m, $_, -1)) {
215677354µs my $offs;
2256772.10ms for (split(/\t/, $_, -1)) {
235703392µs if (defined $offs) {
24264µs $pad = $tabstop - $offs % $tabstop;
25267µs $s .= " " x $pad;
26 }
275703818µs $s .= $_;
28570345.4ms570333.6ms $offs = () = /\PM/g;
# spent 33.6ms making 5703 calls to Text::Tabs::CORE:match, avg 6µs/call
29 }
30 }
311431455µs push(@l, $s);
32 }
331431117µs return @l if wantarray;
341431931µs return $l[0];
35}
36
37sub unexpand
38{
39 my (@l) = @_;
40 my @e;
41 my $x;
42 my $line;
43 my @lines;
44 my $lastbit;
45 my $ts_as_space = " " x $tabstop;
46 for $x (@l) {
47 defined $x or next;
48 @lines = split("\n", $x, -1);
49 for $line (@lines) {
50 $line = expand($line);
51 @e = split(/((?:\PM\pM*){$tabstop})/,$line,-1);
52 $lastbit = pop(@e);
53 $lastbit = ''
54 unless defined $lastbit;
55 $lastbit = "\t"
56 if $lastbit eq $ts_as_space;
57 for $_ (@e) {
58 s/ +$/\t/;
59 }
60 $line = join('',@e, $lastbit);
61 }
62 $x = join("\n", @lines);
63 }
64 return @l if wantarray;
65 return $l[0];
66}
67
6813µs1;
69
70__END__
 
# spent 33.6ms within Text::Tabs::CORE:match which was called 5703 times, avg 6µs/call: # 5703 times (33.6ms+0s) by Text::Tabs::expand at line 28, avg 6µs/call
sub Text::Tabs::CORE:match; # opcode