Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/Literal.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:58:12 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/XML/LibXML/Literal.pm
Statements Executed | 17
Statement Execution Time | 835µs

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 32µs | 113µs | XML::LibXML::Literal::::BEGIN@19XML::LibXML::Literal::BEGIN@19
1 | 1 | 1 | 26µs | 26µs | XML::LibXML::Literal::::BEGIN@11XML::LibXML::Literal::BEGIN@11
1 | 1 | 1 | 26µs | 31µs | XML::LibXML::Literal::::BEGIN@13XML::LibXML::Literal::BEGIN@13
1 | 1 | 1 | 14µs | 78µs | XML::LibXML::Literal::::BEGIN@15XML::LibXML::Literal::BEGIN@15
1 | 1 | 1 | 13µs | 13µs | XML::LibXML::Literal::::BEGIN@12XML::LibXML::Literal::BEGIN@12
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::as_stringXML::LibXML::Literal::as_string
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::as_xmlXML::LibXML::Literal::as_xml
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::cmpXML::LibXML::Literal::cmp
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::evaluateXML::LibXML::Literal::evaluate
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::newXML::LibXML::Literal::new
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::string_valueXML::LibXML::Literal::string_value
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::to_booleanXML::LibXML::Literal::to_boolean
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::to_literalXML::LibXML::Literal::to_literal
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::to_numberXML::LibXML::Literal::to_number
0 | 0 | 0 | 0s | 0s | XML::LibXML::Literal::::valueXML::LibXML::Literal::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: Literal.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::Literal;
11 | 3 | 47µs | 1 | 26µs | # spent 26µs within XML::LibXML::Literal::BEGIN@11 which was called # once (26µs+0s) by XML::LibXML::Number::BEGIN@12 at line 11 use XML::LibXML::Boolean; # spent 26µs making 1 call to XML::LibXML::Literal::BEGIN@11
12 | 3 | 57µs | 1 | 13µs | # spent 13µs within XML::LibXML::Literal::BEGIN@12 which was called # once (13µs+0s) by XML::LibXML::Number::BEGIN@12 at line 12 use XML::LibXML::Number; # spent 13µs making 1 call to XML::LibXML::Literal::BEGIN@12
13 | 3 | 50µs | 2 | 36µs | # spent 31µs (26+5) within XML::LibXML::Literal::BEGIN@13 which was called # once (26µs+5µs) by XML::LibXML::Number::BEGIN@12 at line 13 use strict; # spent 31µs making 1 call to XML::LibXML::Literal::BEGIN@13 # spent 5µs making 1 call to strict::import
14 |  |  |  |  |
15 | 3 | 87µs | 2 | 141µs | # spent 78µs (14+63) within XML::LibXML::Literal::BEGIN@15 which was called # once (14µs+63µs) by XML::LibXML::Number::BEGIN@12 at line 15 use vars qw ($VERSION); # spent 78µs making 1 call to XML::LibXML::Literal::BEGIN@15 # spent 63µs making 1 call to vars::import
16 | 1 | 1µs |  |  | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE
17 |  |  |  |  |
18 |  |  |  |  | use overload
19 |  |  |  |  | # spent 113µs (32+81) within XML::LibXML::Literal::BEGIN@19 which was called # once (32µs+81µs) by XML::LibXML::Number::BEGIN@12 at line 20 '""' => \&value, # spent 81µs making 1 call to overload::import
20 | 3 | 587µs | 1 | 113µs | 'cmp' => \&cmp; # spent 113µs making 1 call to XML::LibXML::Literal::BEGIN@19
21 |  |  |  |  |
22 |  |  |  |  | sub new {
23 |  |  |  |  | my $class = shift;
24 |  |  |  |  | my ($string) = @_;
25 |  |  |  |  |
26 |  |  |  |  | # $string =~ s/&quot;/"/g;
27 |  |  |  |  | # $string =~ s/&apos;/'/g;
28 |  |  |  |  |
29 |  |  |  |  | bless \$string, $class;
30 |  |  |  |  | }
31 |  |  |  |  |
32 |  |  |  |  | sub as_string {
33 |  |  |  |  | my $self = shift;
34 |  |  |  |  | my $string = $$self;
35 |  |  |  |  | $string =~ s/'/&apos;/g;
36 |  |  |  |  | return "'$string'";
37 |  |  |  |  | }
38 |  |  |  |  |
39 |  |  |  |  | sub as_xml {
40 |  |  |  |  | my $self = shift;
41 |  |  |  |  | my $string = $$self;
42 |  |  |  |  | return "<Literal>$string</Literal>\n";
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  | sub value {
46 |  |  |  |  | my $self = shift;
47 |  |  |  |  | $$self;
48 |  |  |  |  | }
49 |  |  |  |  |
50 |  |  |  |  | sub cmp {
51 |  |  |  |  | my $self = shift;
52 |  |  |  |  | my ($cmp, $swap) = @_;
53 |  |  |  |  | if ($swap) {
54 |  |  |  |  | return $cmp cmp $$self;
55 |  |  |  |  | }
56 |  |  |  |  | return $$self cmp $cmp;
57 |  |  |  |  | }
58 |  |  |  |  |
59 |  |  |  |  | sub evaluate {
60 |  |  |  |  | my $self = shift;
61 |  |  |  |  | $self;
62 |  |  |  |  | }
63 |  |  |  |  |
64 |  |  |  |  | sub to_boolean {
65 |  |  |  |  | my $self = shift;
66 |  |  |  |  | return (length($$self) > 0) ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False;
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | sub to_number { return XML::LibXML::Number->new($_[0]->value); }
70 |  |  |  |  | sub to_literal { return $_[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::Literal - Simple string values.
80 |  |  |  |  |
81 |  |  |  |  | =head1 DESCRIPTION
82 |  |  |  |  |
83 |  |  |  |  | In XPath terms a Literal is what we know as a string.
84 |  |  |  |  |
85 |  |  |  |  | =head1 API
86 |  |  |  |  |
87 |  |  |  |  | =head2 new($string)
88 |  |  |  |  |
89 |  |  |  |  | Create a new Literal object with the value in $string. Note that &quot; and
90 |  |  |  |  | &apos; will be converted to " and ' respectively. That is not part of the XPath
91 |  |  |  |  | specification, but I consider it useful. Note though that you have to go
92 |  |  |  |  | to extraordinary lengths in an XML template file (be it XSLT or whatever) to
93 |  |  |  |  | make use of this:
94 |  |  |  |  |
95 |  |  |  |  | <xsl:value-of select="&quot;I'm feeling &amp;quot;sad&amp;quot;&quot;"/>
96 |  |  |  |  |
97 |  |  |  |  | Which produces a Literal of:
98 |  |  |  |  |
99 |  |  |  |  | I'm feeling "sad"
100 |  |  |  |  |
101 |  |  |  |  | =head2 value()
102 |  |  |  |  |
103 |  |  |  |  | Also overloaded as stringification, simply returns the literal string value.
104 |  |  |  |  |
105 |  |  |  |  | =head2 cmp($literal)
106 |  |  |  |  |
107 |  |  |  |  | Returns the equivalent of perl's cmp operator against the given $literal.
108 |  |  |  |  |
109 |  |  |  |  | =cut