Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/Number.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 16:57:28 2010
Reported on Tue May 4 16:59:13 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/Number.pm
Statements Executed | 17
Statement Execution Time | 1.71ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 914µs | 1.18ms | XML::LibXML::Number::::BEGIN@12XML::LibXML::Number::BEGIN@12
1 | 1 | 1 | 36µs | 36µs | XML::LibXML::Number::::BEGIN@11XML::LibXML::Number::BEGIN@11
1 | 1 | 1 | 20µs | 64µs | XML::LibXML::Number::::BEGIN@19XML::LibXML::Number::BEGIN@19
1 | 1 | 1 | 16µs | 22µs | XML::LibXML::Number::::BEGIN@13XML::LibXML::Number::BEGIN@13
1 | 1 | 1 | 14µs | 51µs | XML::LibXML::Number::::BEGIN@15XML::LibXML::Number::BEGIN@15
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::as_stringXML::LibXML::Number::as_string
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::as_xmlXML::LibXML::Number::as_xml
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::cmpXML::LibXML::Number::cmp
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::evaluateXML::LibXML::Number::evaluate
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::newXML::LibXML::Number::new
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::string_valueXML::LibXML::Number::string_value
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::to_booleanXML::LibXML::Number::to_boolean
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::to_literalXML::LibXML::Number::to_literal
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::to_numberXML::LibXML::Number::to_number
0 | 0 | 0 | 0s | 0s | XML::LibXML::Number::::valueXML::LibXML::Number::value

Call graph for these subroutines as a Graphviz dot language file.

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 | 54µs | 1 | 36µs | # spent 36µs within XML::LibXML::Number::BEGIN@11 which was called # once (36µs+0s) by XML::LibXML::Boolean::BEGIN@12 at line 11 use XML::LibXML::Boolean; # spent 36µs making 1 call to XML::LibXML::Number::BEGIN@11
12 | 3 | 216µs | 1 | 1.18ms | # spent 1.18ms (914µs+261µs) within XML::LibXML::Number::BEGIN@12 which was called # once (914µs+261µs) by XML::LibXML::Boolean::BEGIN@12 at line 12 use XML::LibXML::Literal; # spent 1.18ms making 1 call to XML::LibXML::Number::BEGIN@12
13 | 3 | 45µs | 2 | 28µs | # spent 22µs (16+6) within XML::LibXML::Number::BEGIN@13 which was called # once (16µs+6µs) by XML::LibXML::Boolean::BEGIN@12 at line 13 use strict; # spent 22µs making 1 call to XML::LibXML::Number::BEGIN@13 # spent 6µs making 1 call to strict::import
14 |  |  |  |  |
15 | 3 | 100µs | 2 | 88µs | # spent 51µs (14+37) within XML::LibXML::Number::BEGIN@15 which was called # once (14µs+37µs) by XML::LibXML::Boolean::BEGIN@12 at line 15 use vars qw ($VERSION); # spent 51µs making 1 call to XML::LibXML::Number::BEGIN@15 # spent 37µs making 1 call to vars::import
16 | 1 | 2µs |  |  | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
17 |  |  |  |  |
18 |  |  |  |  | use overload
19 | 1 | 16µs | 1 | 44µs | # spent 64µs (20+44) within XML::LibXML::Number::BEGIN@19 which was called # once (20µs+44µs) by XML::LibXML::Boolean::BEGIN@12 at line 21 '""' => \&value, # spent 44µs making 1 call to overload::import
20 |  |  |  |  | '0+' => \&value,
21 | 2 | 1.28ms | 1 | 64µs | '<=>' => \&cmp; # spent 64µ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 | 7µs |  |  | 1;
75 |  |  |  |  | __END__
76 |  |  |  |  |
77 |  |  |  |  | =head1 NAME
78 |  |  |  |  |
79 |  |  |  |  | XML::LibXML::Number - Simple numeric values.
80 |  |  |  |  |
81 |  |  |  |  | =head1 DESCRIPTION
82 |  |  |  |  |
83 |  |  |  |  | This class holds simple numeric values. It doesn't support -0, +/- Infinity,
84 |  |  |  |  | or NaN, as the XPath spec says it should, but I'm not hurting anyone I don't think.
85 |  |  |  |  |
86 |  |  |  |  | =head1 API
87 |  |  |  |  |
88 |  |  |  |  | =head2 new($num)
89 |  |  |  |  |
90 |  |  |  |  | Creates a new XML::LibXML::Number object, with the value in $num. Does some
91 |  |  |  |  | rudimentary numeric checking on $num to ensure it actually is a number.
92 |  |  |  |  |
93 |  |  |  |  | =head2 value()
94 |  |  |  |  |
95 |  |  |  |  | Also as overloaded stringification. Returns the numeric value held.
96 |  |  |  |  |
97 |  |  |  |  | =cut