| Filename | /usr/lib/x86_64-linux-gnu/perl-base/Text/Tabs.pm |
| Statements | Executed 39974 statements in 52.6ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 5703 | 1 | 1 | 33.6ms | 33.6ms | Text::Tabs::CORE:match (opcode) |
| 1431 | 1 | 1 | 18.3ms | 51.9ms | Text::Tabs::expand |
| 1 | 1 | 1 | 7µs | 8µs | diagnostics::BEGIN@1 |
| 1 | 1 | 1 | 3µs | 15µs | diagnostics::BEGIN@1.1 |
| 1 | 1 | 1 | 2µs | 2µs | Text::Tabs::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Text::Tabs::unexpand |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 4 | 38µs | 4 | 36µs | 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 | |||||
| 3 | package Text::Tabs; | ||||
| 4 | |||||
| 5 | 2 | 275µs | 1 | 2µs | # spent 2µs within Text::Tabs::BEGIN@5 which was called:
# once (2µs+0s) by diagnostics::BEGIN@197 at line 5 # spent 2µs making 1 call to Text::Tabs::BEGIN@5 |
| 6 | |||||
| 7 | 1 | 800ns | our @EXPORT = qw( expand unexpand $tabstop ); | ||
| 8 | |||||
| 9 | 1 | 100ns | our $VERSION = '2021.0814'; | ||
| 10 | 1 | 100ns | our $SUBVERSION = 'modern'; # back-compat vestige | ||
| 11 | |||||
| 12 | 1 | 100ns | our $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 | ||||
| 15 | 1431 | 117µs | my @l; | ||
| 16 | my $pad; | ||||
| 17 | 1431 | 368µs | for ( @_ ) { | ||
| 18 | 1431 | 137µs | defined or do { push @l, ''; next }; | ||
| 19 | 1431 | 183µs | my $s = ''; | ||
| 20 | 1431 | 922µs | for (split(/^/m, $_, -1)) { | ||
| 21 | 5677 | 354µs | my $offs; | ||
| 22 | 5677 | 2.10ms | for (split(/\t/, $_, -1)) { | ||
| 23 | 5703 | 392µs | if (defined $offs) { | ||
| 24 | 26 | 4µs | $pad = $tabstop - $offs % $tabstop; | ||
| 25 | 26 | 7µs | $s .= " " x $pad; | ||
| 26 | } | ||||
| 27 | 5703 | 818µs | $s .= $_; | ||
| 28 | 5703 | 45.4ms | 5703 | 33.6ms | $offs = () = /\PM/g; # spent 33.6ms making 5703 calls to Text::Tabs::CORE:match, avg 6µs/call |
| 29 | } | ||||
| 30 | } | ||||
| 31 | 1431 | 455µs | push(@l, $s); | ||
| 32 | } | ||||
| 33 | 1431 | 117µs | return @l if wantarray; | ||
| 34 | 1431 | 931µs | return $l[0]; | ||
| 35 | } | ||||
| 36 | |||||
| 37 | sub 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 | |||||
| 68 | 1 | 3µs | 1; | ||
| 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 |