Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/Number.pm |
Statements | Executed 14 statements in 1.08ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.50ms | 1.60ms | BEGIN@12 | XML::LibXML::Number::
1 | 1 | 1 | 12µs | 12µs | BEGIN@11 | XML::LibXML::Number::
1 | 1 | 1 | 8µs | 30µs | BEGIN@20 | XML::LibXML::Number::
1 | 1 | 1 | 6µs | 10µs | BEGIN@14 | XML::LibXML::Number::
1 | 1 | 1 | 6µs | 16µs | BEGIN@13 | XML::LibXML::Number::
1 | 1 | 1 | 6µs | 22µs | BEGIN@16 | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | as_string | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | as_xml | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | cmp | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | evaluate | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | new | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | string_value | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | to_boolean | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | to_literal | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | to_number | XML::LibXML::Number::
0 | 0 | 0 | 0s | 0s | value | XML::LibXML::Number::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # $Id$ | ||||
2 | # | ||||
3 | # This is free software, you may use it and distribute it under the same terms as | ||||
4 | # Perl itself. | ||||
5 | # | ||||
6 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||
7 | # | ||||
8 | # | ||||
9 | |||||
10 | package XML::LibXML::Number; | ||||
11 | 2 | 30µs | 1 | 12µs | # spent 12µs within XML::LibXML::Number::BEGIN@11 which was called:
# once (12µs+0s) by XML::LibXML::Boolean::BEGIN@12 at line 11 # spent 12µs making 1 call to XML::LibXML::Number::BEGIN@11 |
12 | 2 | 699µs | 1 | 1.60ms | # spent 1.60ms (1.50+100µs) within XML::LibXML::Number::BEGIN@12 which was called:
# once (1.50ms+100µs) by XML::LibXML::Boolean::BEGIN@12 at line 12 # spent 1.60ms making 1 call to XML::LibXML::Number::BEGIN@12 |
13 | 2 | 19µs | 2 | 25µs | # spent 16µs (6+10) within XML::LibXML::Number::BEGIN@13 which was called:
# once (6µs+10µs) by XML::LibXML::Boolean::BEGIN@12 at line 13 # spent 16µs making 1 call to XML::LibXML::Number::BEGIN@13
# spent 10µs making 1 call to strict::import |
14 | 2 | 22µs | 2 | 14µs | # spent 10µs (6+4) within XML::LibXML::Number::BEGIN@14 which was called:
# once (6µs+4µs) by XML::LibXML::Boolean::BEGIN@12 at line 14 # spent 10µs making 1 call to XML::LibXML::Number::BEGIN@14
# spent 4µs making 1 call to warnings::import |
15 | |||||
16 | 2 | 42µs | 2 | 39µs | # spent 22µs (6+16) within XML::LibXML::Number::BEGIN@16 which was called:
# once (6µs+16µs) by XML::LibXML::Boolean::BEGIN@12 at line 16 # spent 22µs making 1 call to XML::LibXML::Number::BEGIN@16
# spent 16µs making 1 call to vars::import |
17 | 1 | 400ns | $VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE | ||
18 | |||||
19 | use overload | ||||
20 | 1 | 5µs | 1 | 21µs | # spent 30µs (8+21) within XML::LibXML::Number::BEGIN@20 which was called:
# once (8µs+21µs) by XML::LibXML::Boolean::BEGIN@12 at line 22 # spent 21µs making 1 call to overload::import |
21 | '0+' => \&value, | ||||
22 | 1 | 262µs | 1 | 30µs | '<=>' => \&cmp; # spent 30µs making 1 call to XML::LibXML::Number::BEGIN@20 |
23 | |||||
24 | sub new { | ||||
25 | my $class = shift; | ||||
26 | my $number = shift; | ||||
27 | if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { | ||||
28 | $number = undef; | ||||
29 | } | ||||
30 | else { | ||||
31 | $number =~ s/\s+//g; | ||||
32 | } | ||||
33 | bless \$number, $class; | ||||
34 | } | ||||
35 | |||||
36 | sub as_string { | ||||
37 | my $self = shift; | ||||
38 | defined $$self ? $$self : 'NaN'; | ||||
39 | } | ||||
40 | |||||
41 | sub as_xml { | ||||
42 | my $self = shift; | ||||
43 | return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n"; | ||||
44 | } | ||||
45 | |||||
46 | sub value { | ||||
47 | my $self = shift; | ||||
48 | $$self; | ||||
49 | } | ||||
50 | |||||
51 | sub cmp { | ||||
52 | my $self = shift; | ||||
53 | my ($other, $swap) = @_; | ||||
54 | if ($swap) { | ||||
55 | return $other <=> $$self; | ||||
56 | } | ||||
57 | return $$self <=> $other; | ||||
58 | } | ||||
59 | |||||
60 | sub evaluate { | ||||
61 | my $self = shift; | ||||
62 | $self; | ||||
63 | } | ||||
64 | |||||
65 | sub to_boolean { | ||||
66 | my $self = shift; | ||||
67 | return $$self ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; | ||||
68 | } | ||||
69 | |||||
70 | sub to_literal { XML::LibXML::Literal->new($_[0]->as_string); } | ||||
71 | sub to_number { $_[0]; } | ||||
72 | |||||
73 | sub string_value { return $_[0]->value } | ||||
74 | |||||
75 | 1 | 2µs | 1; | ||
76 | __END__ |