Filename | /usr/lib/perl5/XML/LibXML/Boolean.pm |
Statements | Executed 17 statements in 627µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 568µs | 1.61ms | BEGIN@12 | XML::LibXML::Boolean::
1 | 1 | 1 | 37µs | 99µs | BEGIN@21 | XML::LibXML::Boolean::
1 | 1 | 1 | 20µs | 44µs | BEGIN@16 | XML::LibXML::Boolean::
1 | 1 | 1 | 9µs | 10µs | BEGIN@13 | XML::LibXML::Boolean::
1 | 1 | 1 | 9µs | 13µs | BEGIN@14 | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | False | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | True | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | cmp | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | new | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | string_value | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | to_boolean | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | to_literal | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | to_number | XML::LibXML::Boolean::
0 | 0 | 0 | 0s | 0s | value | XML::LibXML::Boolean::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # $Id: Boolean.pm 785 2009-07-16 14:17:46Z pajas $ | ||||
2 | # | ||||
3 | # | ||||
4 | # This is free software, you may use it and distribute it under the same terms as | ||||
5 | # Perl itself. | ||||
6 | # | ||||
7 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||
8 | # | ||||
9 | # | ||||
10 | |||||
11 | package XML::LibXML::Boolean; | ||||
12 | 3 | 100µs | 2 | 1.62ms | # spent 1.61ms (568µs+1.04) within XML::LibXML::Boolean::BEGIN@12 which was called:
# once (568µs+1.04ms) by XML::LibXML::NodeList::BEGIN@12 at line 12 # spent 1.61ms making 1 call to XML::LibXML::Boolean::BEGIN@12
# spent 3µs making 1 call to UNIVERSAL::import |
13 | 3 | 27µs | 2 | 12µs | # spent 10µs (9+1) within XML::LibXML::Boolean::BEGIN@13 which was called:
# once (9µs+1µs) by XML::LibXML::NodeList::BEGIN@12 at line 13 # spent 10µs making 1 call to XML::LibXML::Boolean::BEGIN@13
# spent 1µs making 1 call to UNIVERSAL::import |
14 | 3 | 27µs | 2 | 16µs | # spent 13µs (9+4) within XML::LibXML::Boolean::BEGIN@14 which was called:
# once (9µs+4µs) by XML::LibXML::NodeList::BEGIN@12 at line 14 # spent 13µs making 1 call to XML::LibXML::Boolean::BEGIN@14
# spent 4µs making 1 call to strict::import |
15 | |||||
16 | 3 | 74µs | 2 | 68µs | # spent 44µs (20+24) within XML::LibXML::Boolean::BEGIN@16 which was called:
# once (20µs+24µs) by XML::LibXML::NodeList::BEGIN@12 at line 16 # spent 44µs making 1 call to XML::LibXML::Boolean::BEGIN@16
# spent 24µs making 1 call to vars::import |
17 | |||||
18 | 1 | 700ns | $VERSION = "1.70"; # VERSION TEMPLATE: DO NOT CHANGE | ||
19 | |||||
20 | use overload | ||||
21 | 1 | 62µs | # spent 99µs (37+62) within XML::LibXML::Boolean::BEGIN@21 which was called:
# once (37µs+62µs) by XML::LibXML::NodeList::BEGIN@12 at line 22 # spent 62µs making 1 call to overload::import | ||
22 | 3 | 396µs | 1 | 99µs | '<=>' => \&cmp; # spent 99µs making 1 call to XML::LibXML::Boolean::BEGIN@21 |
23 | |||||
24 | sub new { | ||||
25 | my $class = shift; | ||||
26 | my ($param) = @_; | ||||
27 | my $val = $param ? 1 : 0; | ||||
28 | bless \$val, $class; | ||||
29 | } | ||||
30 | |||||
31 | sub True { | ||||
32 | my $class = shift; | ||||
33 | my $val = 1; | ||||
34 | bless \$val, $class; | ||||
35 | } | ||||
36 | |||||
37 | sub False { | ||||
38 | my $class = shift; | ||||
39 | my $val = 0; | ||||
40 | bless \$val, $class; | ||||
41 | } | ||||
42 | |||||
43 | sub value { | ||||
44 | my $self = shift; | ||||
45 | $$self; | ||||
46 | } | ||||
47 | |||||
48 | sub cmp { | ||||
49 | my $self = shift; | ||||
50 | my ($other, $swap) = @_; | ||||
51 | if ($swap) { | ||||
52 | return $other <=> $$self; | ||||
53 | } | ||||
54 | return $$self <=> $other; | ||||
55 | } | ||||
56 | |||||
57 | sub to_number { XML::LibXML::Number->new($_[0]->value); } | ||||
58 | sub to_boolean { $_[0]; } | ||||
59 | sub to_literal { XML::LibXML::Literal->new($_[0]->value ? "true" : "false"); } | ||||
60 | |||||
61 | sub string_value { return $_[0]->to_literal->value; } | ||||
62 | |||||
63 | 1 | 3µs | 1; | ||
64 | __END__ |