← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:12 2010

File /usr/lib/perl5/XML/LibXML/Boolean.pm
Statements Executed 17
Total Time 0.0005338 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sXML::LibXML::Boolean::::BEGINXML::LibXML::Boolean::BEGIN
0000s0sXML::LibXML::Boolean::::FalseXML::LibXML::Boolean::False
0000s0sXML::LibXML::Boolean::::TrueXML::LibXML::Boolean::True
0000s0sXML::LibXML::Boolean::::cmpXML::LibXML::Boolean::cmp
0000s0sXML::LibXML::Boolean::::newXML::LibXML::Boolean::new
0000s0sXML::LibXML::Boolean::::string_valueXML::LibXML::Boolean::string_value
0000s0sXML::LibXML::Boolean::::to_booleanXML::LibXML::Boolean::to_boolean
0000s0sXML::LibXML::Boolean::::to_literalXML::LibXML::Boolean::to_literal
0000s0sXML::LibXML::Boolean::::to_numberXML::LibXML::Boolean::to_number
0000s0sXML::LibXML::Boolean::::valueXML::LibXML::Boolean::value
LineStmts.Exclusive
Time
Avg.Code
1# $Id: Boolean.pm 709 2008-01-29 21:01:32Z pajas $
2# Copyright 2001-2002, AxKit.com Ltd. All rights reserved.
3
4package XML::LibXML::Boolean;
53113µs38µsuse XML::LibXML::Number;
# spent 8µs making 1 call to import
6320µs7µsuse XML::LibXML::Literal;
# spent 3µs making 1 call to import
7327µs9µsuse strict;
# spent 11µs making 1 call to strict::import
8
9349µs16µsuse vars qw ($VERSION);
# spent 28µs making 1 call to vars::import
10
111600ns600ns$VERSION = "1.66"; # VERSION TEMPLATE: DO NOT CHANGE
12
13use overload
14118µs18µs '""' => \&value,
# spent 45µs making 1 call to overload::import
152303µs151µs '<=>' => \&cmp;
16
17sub new {
18 my $class = shift;
19 my ($param) = @_;
20 my $val = $param ? 1 : 0;
21 bless \$val, $class;
22}
23
24sub True {
25 my $class = shift;
26 my $val = 1;
27 bless \$val, $class;
28}
29
30sub False {
31 my $class = shift;
32 my $val = 0;
33 bless \$val, $class;
34}
35
36sub value {
37 my $self = shift;
38 $$self;
39}
40
41sub cmp {
42 my $self = shift;
43 my ($other, $swap) = @_;
44 if ($swap) {
45 return $other <=> $$self;
46 }
47 return $$self <=> $other;
48}
49
50sub to_number { XML::LibXML::Number->new($_[0]->value); }
51sub to_boolean { $_[0]; }
52sub to_literal { XML::LibXML::Literal->new($_[0]->value ? "true" : "false"); }
53
54sub string_value { return $_[0]->to_literal->value; }
55
5613µs3µs1;
57__END__
58
59=head1 NAME
60
61XML::LibXML::Boolean - Boolean true/false values
62
63=head1 DESCRIPTION
64
65XML::LibXML::Boolean objects implement simple boolean true/false objects.
66
67=head1 API
68
69=head2 XML::LibXML::Boolean->True
70
71Creates a new Boolean object with a true value.
72
73=head2 XML::LibXML::Boolean->False
74
75Creates a new Boolean object with a false value.
76
77=head2 value()
78
79Returns true or false.
80
81=head2 to_literal()
82
83Returns the string "true" or "false".
84
85=cut