← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:36 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Exception.pm
StatementsExecuted 8 statements in 447µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11136µs40µsYAML::PP::Parser::::BEGIN@1.286 YAML::PP::Parser::BEGIN@1.286
11110µs35µsYAML::PP::Exception::::BEGIN@7YAML::PP::Exception::BEGIN@7
1116µs47µsYAML::PP::Parser::::BEGIN@2.287 YAML::PP::Parser::BEGIN@2.287
0000s0sYAML::PP::Exception::::newYAML::PP::Exception::new
0000s0sYAML::PP::Exception::::to_stringYAML::PP::Exception::to_string
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1231µs244µs
# spent 40µs (36+4) within YAML::PP::Parser::BEGIN@1.286 which was called: # once (36µs+4µs) by YAML::PP::Parser::BEGIN@20 at line 1
use strict;
# spent 40µs making 1 call to YAML::PP::Parser::BEGIN@1.286 # spent 4µs making 1 call to strict::import
2259µs288µs
# spent 47µs (6+41) within YAML::PP::Parser::BEGIN@2.287 which was called: # once (6µs+41µs) by YAML::PP::Parser::BEGIN@20 at line 2
use warnings;
# spent 47µs making 1 call to YAML::PP::Parser::BEGIN@2.287 # spent 41µs making 1 call to warnings::import
3package YAML::PP::Exception;
4
511µsour $VERSION = '0.035'; # VERSION
6
72352µs260µs
# spent 35µs (10+25) within YAML::PP::Exception::BEGIN@7 which was called: # once (10µs+25µs) by YAML::PP::Parser::BEGIN@20 at line 7
use overload '""' => \&to_string;
# spent 35µs making 1 call to YAML::PP::Exception::BEGIN@7 # spent 25µs making 1 call to overload::import
8
9sub new {
10 my ($class, %args) = @_;
11 my $self = bless {
12 line => $args{line},
13 msg => $args{msg},
14 next => $args{next},
15 where => $args{where},
16 yaml => $args{yaml},
17 got => $args{got},
18 expected => $args{expected},
19 column => $args{column},
20 }, $class;
21 return $self;
22}
23
24sub to_string {
25 my ($self) = @_;
26 my $next = $self->{next};
27 my $line = $self->{line};
28 my $column = $self->{column};
29
30 my $yaml = '';
31 for my $token (@$next) {
32 last if $token->{name} eq 'EOL';
33 $yaml .= $token->{value};
34 }
35 $column = '???' unless defined $column;
36
37 my $remaining_yaml = $self->{yaml};
38 $remaining_yaml = '' unless defined $remaining_yaml;
39 $yaml .= $remaining_yaml;
40 {
41 local $@; # avoid bug in old Data::Dumper
42 require Data::Dumper;
43 local $Data::Dumper::Useqq = 1;
44 local $Data::Dumper::Terse = 1;
45 $yaml = Data::Dumper->Dump([$yaml], ['yaml']);
46 chomp $yaml;
47 }
48
49 my $lines = 5;
50 my @fields;
51
52 if ($self->{got} and $self->{expected}) {
53 $lines = 6;
54 $line = $self->{got}->{line};
55 $column = $self->{got}->{column} + 1;
56 @fields = (
57 "Line" => $line,
58 "Column" => $column,
59 "Expected", join(" ", @{ $self->{expected} }),
60 "Got", $self->{got}->{name},
61 "Where", $self->{where},
62 "YAML", $yaml,
63 );
64 }
65 else {
66 @fields = (
67 "Line" => $line,
68 "Column" => $column,
69 "Message", $self->{msg},
70 "Where", $self->{where},
71 "YAML", $yaml,
72 );
73 }
74 my $fmt = join "\n", ("%-10s: %s") x $lines;
75 my $string = sprintf $fmt, @fields;
76 return $string;
77}
78
7914µs1;