← 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:10 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Number/Binary.pm
StatementsExecuted 9 statements in 298µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs24µsPPI::Token::Number::Binary::::BEGIN@29PPI::Token::Number::Binary::BEGIN@29
11112µs12µsPPI::Token::Number::Binary::::BEGIN@33PPI::Token::Number::Binary::BEGIN@33
1116µs38µsPPI::Token::Number::Binary::::BEGIN@32PPI::Token::Number::Binary::BEGIN@32
1113µs3µsPPI::Token::Number::Binary::::BEGIN@30PPI::Token::Number::Binary::BEGIN@30
0000s0sPPI::Token::Number::Binary::::__TOKENIZER__on_charPPI::Token::Number::Binary::__TOKENIZER__on_char
0000s0sPPI::Token::Number::Binary::::basePPI::Token::Number::Binary::base
0000s0sPPI::Token::Number::Binary::::literalPPI::Token::Number::Binary::literal
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package PPI::Token::Number::Binary;
2
3=pod
4
5=head1 NAME
6
7PPI::Token::Number::Binary - Token class for a binary number
8
9=head1 SYNOPSIS
10
11 $n = 0b1110011; # binary integer
12
13=head1 INHERITANCE
14
15 PPI::Token::Number::Binary
16 isa PPI::Token::Number
17 isa PPI::Token
18 isa PPI::Element
19
20=head1 DESCRIPTION
21
22The C<PPI::Token::Number::Binary> class is used for tokens that
23represent base-2 numbers.
24
25=head1 METHODS
26
27=cut
28
29220µs236µs
# spent 24µs (12+12) within PPI::Token::Number::Binary::BEGIN@29 which was called: # once (12µs+12µs) by PPI::Token::BEGIN@43 at line 29
use strict;
# spent 24µs making 1 call to PPI::Token::Number::Binary::BEGIN@29 # spent 12µs making 1 call to strict::import
30224µs13µs
# spent 3µs within PPI::Token::Number::Binary::BEGIN@30 which was called: # once (3µs+0s) by PPI::Token::BEGIN@43 at line 30
use PPI::Token::Number ();
# spent 3µs making 1 call to PPI::Token::Number::Binary::BEGIN@30
31
32231µs270µs
# spent 38µs (6+32) within PPI::Token::Number::Binary::BEGIN@32 which was called: # once (6µs+32µs) by PPI::Token::BEGIN@43 at line 32
use vars qw{$VERSION @ISA};
# spent 38µs making 1 call to PPI::Token::Number::Binary::BEGIN@32 # spent 32µs making 1 call to vars::import
33
# spent 12µs within PPI::Token::Number::Binary::BEGIN@33 which was called: # once (12µs+0s) by PPI::Token::BEGIN@43 at line 36
BEGIN {
341400ns $VERSION = '1.215';
35112µs @ISA = 'PPI::Token::Number';
361208µs112µs}
# spent 12µs making 1 call to PPI::Token::Number::Binary::BEGIN@33
37
38=pod
39
40=head2 base
41
42Returns the base for the number: 2.
43
44=cut
45
46sub base {
47 return 2;
48}
49
50=pod
51
52=head2 literal
53
54Return the numeric value of this token.
55
56=cut
57
58sub literal {
59 my $self = shift;
60 return if $self->{_error};
61 my $str = $self->_literal;
62 my $neg = $str =~ s/^\-//;
63 $str =~ s/^0b//;
64 my $val = 0;
65 for my $bit ( $str =~ m/(.)/g ) {
66 $val = $val * 2 + $bit;
67 }
68 return $neg ? -$val : $val;
69}
70
- -
75#####################################################################
76# Tokenizer Methods
77
78sub __TOKENIZER__on_char {
79 my $class = shift;
80 my $t = shift;
81 my $char = substr( $t->{line}, $t->{line_cursor}, 1 );
82
83 # Allow underscores straight through
84 return 1 if $char eq '_';
85
86 if ( $char =~ /[\w\d]/ ) {
87 unless ( $char eq '1' or $char eq '0' ) {
88 # Add a warning if it contains non-hex chars
89 $t->{token}->{_error} = "Illegal character in binary number '$char'";
90 }
91 return 1;
92 }
93
94 # Doesn't fit a special case, or is after the end of the token
95 # End of token.
96 $t->_finalize_token->__TOKENIZER__on_char( $t );
97}
98
9912µs1;
100
101=pod
102
103=head1 SUPPORT
104
105See the L<support section|PPI/SUPPORT> in the main module.
106
107=head1 AUTHOR
108
109Chris Dolan E<lt>cdolan@cpan.orgE<gt>
110
111=head1 COPYRIGHT
112
113Copyright 2006 Chris Dolan.
114
115This program is free software; you can redistribute
116it and/or modify it under the same terms as Perl itself.
117
118The full text of the license can be found in the
119LICENSE file included with this module.
120
121=cut