Profile of /usr/local/lib/perl5/5.10.1/bytes.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:22 2010

File | /usr/local/lib/perl5/5.10.1/bytes.pm
Statements Executed | 22
Statement Execution Time | 150µs

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
19 | 19 | 12 | 61µs | 61µs | bytes::::importbytes::import
0 | 0 | 0 | 0s | 0s | bytes::::AUTOLOADbytes::AUTOLOAD
0 | 0 | 0 | 0s | 0s | bytes::::unimportbytes::unimport

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package bytes;
2 |  |  |  |  |
3 | 1 | 500ns |  |  | our $VERSION = '1.03';
4 |  |  |  |  |
5 | 1 | 100ns |  |  | $bytes::hint_bits = 0x00000008;
6 |  |  |  |  |
7 |  |  |  |  | # spent 61µs within bytes::import which was called 19 times, avg 3µs/call: # once (8µs+0s) by Compress::Raw::Zlib::BEGIN@13 at line 13 of Compress/Raw/Zlib.pm # once (5µs+0s) by IO::Uncompress::RawInflate::BEGIN@6 at line 6 of IO/Uncompress/RawInflate.pm # once (5µs+0s) by IO::Uncompress::Gunzip::BEGIN@10 at line 10 of IO/Uncompress/Gunzip.pm # once (5µs+0s) by UUID::Tiny::BEGIN@309 at line 309 of UUID/Tiny.pm # once (4µs+0s) by Data::Dumper::BEGIN@683 at line 683 of Data/Dumper.pm # once (4µs+0s) by DateTime::Format::Strptime::BEGIN@540 at line 540 of DateTime/Format/Strptime.pm # once (4µs+0s) by XML::Bare::BEGIN@524 at line 524 of XML/Bare.pm # once (3µs+0s) by UUID::Tiny::BEGIN@639 at line 639 of UUID/Tiny.pm # once (3µs+0s) by IO::Compress::Base::Common::BEGIN@5 at line 5 of IO/Compress/Base/Common.pm # once (2µs+0s) by IO::Uncompress::Adapter::Inflate::BEGIN@5 at line 5 of IO/Uncompress/Adapter/Inflate.pm # once (2µs+0s) by IO::Compress::Gzip::Constants::BEGIN@5 at line 5 of IO/Compress/Gzip/Constants.pm # once (2µs+0s) by UUID::Tiny::BEGIN@756 at line 756 of UUID/Tiny.pm # once (2µs+0s) by UUID::Tiny::BEGIN@516 at line 516 of UUID/Tiny.pm # once (2µs+0s) by UUID::Tiny::BEGIN@573 at line 573 of UUID/Tiny.pm # once (2µs+0s) by DateTime::Format::Strptime::BEGIN@550 at line 550 of DateTime/Format/Strptime.pm # once (2µs+0s) by UUID::Tiny::BEGIN@594 at line 594 of UUID/Tiny.pm # once (2µs+0s) by IO::Compress::Zlib::Extra::BEGIN@7 at line 7 of IO/Compress/Zlib/Extra.pm # once (2µs+0s) by IO::Uncompress::Base::BEGIN@6 at line 6 of IO/Uncompress/Base.pm # once (2µs+0s) by UUID::Tiny::BEGIN@550 at line 550 of UUID/Tiny.pm sub import {
8 | 19 | 145µs |  |  | $^H |= $bytes::hint_bits;
9 |  |  |  |  | }
10 |  |  |  |  |
11 |  |  |  |  | sub unimport {
12 |  |  |  |  | $^H &= ~$bytes::hint_bits;
13 |  |  |  |  | }
14 |  |  |  |  |
15 |  |  |  |  | sub AUTOLOAD {
16 |  |  |  |  | require "bytes_heavy.pl";
17 |  |  |  |  | goto &$AUTOLOAD if defined &$AUTOLOAD;
18 |  |  |  |  | require Carp;
19 |  |  |  |  | Carp::croak("Undefined subroutine $AUTOLOAD called");
20 |  |  |  |  | }
21 |  |  |  |  |
22 |  |  |  |  | sub length (_);
23 |  |  |  |  | sub chr (_);
24 |  |  |  |  | sub ord (_);
25 |  |  |  |  | sub substr ($$;$$);
26 |  |  |  |  | sub index ($$;$);
27 |  |  |  |  | sub rindex ($$;$);
28 |  |  |  |  |
29 | 1 | 4µs |  |  | 1;
30 |  |  |  |  | __END__
31 |  |  |  |  |
32 |  |  |  |  | =head1 NAME
33 |  |  |  |  |
34 |  |  |  |  | bytes - Perl pragma to force byte semantics rather than character semantics
35 |  |  |  |  |
36 |  |  |  |  | =head1 SYNOPSIS
37 |  |  |  |  |
38 |  |  |  |  | use bytes;
39 |  |  |  |  | ... chr(...); # or bytes::chr
40 |  |  |  |  | ... index(...); # or bytes::index
41 |  |  |  |  | ... length(...); # or bytes::length
42 |  |  |  |  | ... ord(...); # or bytes::ord
43 |  |  |  |  | ... rindex(...); # or bytes::rindex
44 |  |  |  |  | ... substr(...); # or bytes::substr
45 |  |  |  |  | no bytes;
46 |  |  |  |  |
47 |  |  |  |  |
48 |  |  |  |  | =head1 DESCRIPTION
49 |  |  |  |  |
50 |  |  |  |  | The C<use bytes> pragma disables character semantics for the rest of the
51 |  |  |  |  | lexical scope in which it appears. C<no bytes> can be used to reverse
52 |  |  |  |  | the effect of C<use bytes> within the current lexical scope.
53 |  |  |  |  |
54 |  |  |  |  | Perl normally assumes character semantics in the presence of character
55 |  |  |  |  | data (i.e. data that has come from a source that has been marked as
56 |  |  |  |  | being of a particular character encoding). When C<use bytes> is in
57 |  |  |  |  | effect, the encoding is temporarily ignored, and each string is treated
58 |  |  |  |  | as a series of bytes.
59 |  |  |  |  |
60 |  |  |  |  | As an example, when Perl sees C<$x = chr(400)>, it encodes the character
61 |  |  |  |  | in UTF-8 and stores it in $x. Then it is marked as character data, so,
62 |  |  |  |  | for instance, C<length $x> returns C<1>. However, in the scope of the
63 |  |  |  |  | C<bytes> pragma, $x is treated as a series of bytes - the bytes that make
64 |  |  |  |  | up the UTF8 encoding - and C<length $x> returns C<2>:
65 |  |  |  |  |
66 |  |  |  |  | $x = chr(400);
67 |  |  |  |  | print "Length is ", length $x, "\n"; # "Length is 1"
68 |  |  |  |  | printf "Contents are %vd\n", $x; # "Contents are 400"
69 |  |  |  |  | {
70 |  |  |  |  | use bytes; # or "require bytes; bytes::length()"
71 |  |  |  |  | print "Length is ", length $x, "\n"; # "Length is 2"
72 |  |  |  |  | printf "Contents are %vd\n", $x; # "Contents are 198.144"
73 |  |  |  |  | }
74 |  |  |  |  |
75 |  |  |  |  | chr(), ord(), substr(), index() and rindex() behave similarly.
76 |  |  |  |  |
77 |  |  |  |  | For more on the implications and differences between character
78 |  |  |  |  | semantics and byte semantics, see L<perluniintro> and L<perlunicode>.
79 |  |  |  |  |
80 |  |  |  |  | =head1 LIMITATIONS
81 |  |  |  |  |
82 |  |  |  |  | bytes::substr() does not work as an lvalue().
83 |  |  |  |  |
84 |  |  |  |  | =head1 SEE ALSO
85 |  |  |  |  |
86 |  |  |  |  | L<perluniintro>, L<perlunicode>, L<utf8>
87 |  |  |  |  |
88 |  |  |  |  | =cut