Filename | /usr/lib/perl5/XML/LibXML/Number.pm |
Statements | Executed 17 statements in 654µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 619µs | 887µs | BEGIN@12 | XML::LibXML::Number::
1 | 1 | 1 | 25µs | 27µs | BEGIN@11 | XML::LibXML::Number::
1 | 1 | 1 | 20µs | 57µs | BEGIN@19 | XML::LibXML::Number::
1 | 1 | 1 | 14µs | 18µs | BEGIN@13 | XML::LibXML::Number::
1 | 1 | 1 | 11µs | 53µs | BEGIN@15 | 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: Number.pm 785 2009-07-16 14:17:46Z pajas $ | ||||
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 | 3 | 36µs | 2 | 30µs | # spent 27µs (25+3) within XML::LibXML::Number::BEGIN@11 which was called:
# once (25µs+3µs) by XML::LibXML::Boolean::BEGIN@12 at line 11 # spent 27µs making 1 call to XML::LibXML::Number::BEGIN@11
# spent 3µs making 1 call to UNIVERSAL::import |
12 | 3 | 148µs | 2 | 890µs | # spent 887µs (619+268) within XML::LibXML::Number::BEGIN@12 which was called:
# once (619µs+268µs) by XML::LibXML::Boolean::BEGIN@12 at line 12 # spent 887µs making 1 call to XML::LibXML::Number::BEGIN@12
# spent 3µs making 1 call to UNIVERSAL::import |
13 | 3 | 32µs | 2 | 22µs | # spent 18µs (14+4) within XML::LibXML::Number::BEGIN@13 which was called:
# once (14µs+4µs) by XML::LibXML::Boolean::BEGIN@12 at line 13 # spent 18µs making 1 call to XML::LibXML::Number::BEGIN@13
# spent 4µs making 1 call to strict::import |
14 | |||||
15 | 3 | 60µs | 2 | 94µs | # spent 53µs (11+41) within XML::LibXML::Number::BEGIN@15 which was called:
# once (11µs+41µs) by XML::LibXML::Boolean::BEGIN@12 at line 15 # spent 53µs making 1 call to XML::LibXML::Number::BEGIN@15
# spent 41µs making 1 call to vars::import |
16 | 1 | 600ns | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE | ||
17 | |||||
18 | use overload | ||||
19 | 1 | 14µs | 1 | 37µs | # spent 57µs (20+37) within XML::LibXML::Number::BEGIN@19 which was called:
# once (20µs+37µs) by XML::LibXML::Boolean::BEGIN@12 at line 21 # spent 37µs making 1 call to overload::import |
20 | '0+' => \&value, | ||||
21 | 2 | 362µs | 1 | 57µs | '<=>' => \&cmp; # spent 57µs making 1 call to XML::LibXML::Number::BEGIN@19 |
22 | |||||
23 | sub new { | ||||
24 | my $class = shift; | ||||
25 | my $number = shift; | ||||
26 | if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { | ||||
27 | $number = undef; | ||||
28 | } | ||||
29 | else { | ||||
30 | $number =~ s/\s+//g; | ||||
31 | } | ||||
32 | bless \$number, $class; | ||||
33 | } | ||||
34 | |||||
35 | sub as_string { | ||||
36 | my $self = shift; | ||||
37 | defined $$self ? $$self : 'NaN'; | ||||
38 | } | ||||
39 | |||||
40 | sub as_xml { | ||||
41 | my $self = shift; | ||||
42 | return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n"; | ||||
43 | } | ||||
44 | |||||
45 | sub value { | ||||
46 | my $self = shift; | ||||
47 | $$self; | ||||
48 | } | ||||
49 | |||||
50 | sub cmp { | ||||
51 | my $self = shift; | ||||
52 | my ($other, $swap) = @_; | ||||
53 | if ($swap) { | ||||
54 | return $other <=> $$self; | ||||
55 | } | ||||
56 | return $$self <=> $other; | ||||
57 | } | ||||
58 | |||||
59 | sub evaluate { | ||||
60 | my $self = shift; | ||||
61 | $self; | ||||
62 | } | ||||
63 | |||||
64 | sub to_boolean { | ||||
65 | my $self = shift; | ||||
66 | return $$self ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; | ||||
67 | } | ||||
68 | |||||
69 | sub to_literal { XML::LibXML::Literal->new($_[0]->as_string); } | ||||
70 | sub to_number { $_[0]; } | ||||
71 | |||||
72 | sub string_value { return $_[0]->value } | ||||
73 | |||||
74 | 1 | 3µs | 1; | ||
75 | __END__ |