| Filename | /usr/local/share/perl/5.18.2/Data/GUID.pm |
| Statements | Executed 110 statements in 3.52ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 3.30ms | 8.07ms | Data::GUID::BEGIN@353 |
| 1 | 1 | 1 | 1.69ms | 2.01ms | Data::GUID::BEGIN@8 |
| 2 | 2 | 1 | 1.51ms | 1.51ms | main::CORE:print (opcode) |
| 1 | 1 | 1 | 1.33ms | 2.13ms | Data::GUID::BEGIN@7 |
| 2 | 2 | 1 | 330µs | 330µs | main::CORE:open (opcode) |
| 1 | 1 | 1 | 314µs | 317µs | Data::GUID::BEGIN@85 |
| 1 | 1 | 1 | 103µs | 103µs | main::CORE:syswrite (opcode) |
| 1 | 1 | 1 | 70µs | 112µs | Data::GUID::__ANON__[:147] |
| 3 | 1 | 1 | 60µs | 60µs | Data::GUID::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 58µs | 125µs | Data::GUID::BEGIN@105 |
| 1 | 1 | 1 | 50µs | 336µs | Data::GUID::BEGIN@323 |
| 1 | 1 | 1 | 38µs | 38µs | main::CORE:close (opcode) |
| 1 | 1 | 1 | 36µs | 357µs | Data::GUID::BEGIN@152 |
| 3 | 1 | 1 | 32µs | 171µs | Data::GUID::_install_from_method |
| 1 | 1 | 1 | 28µs | 28µs | Data::GUID::as_binary |
| 2 | 2 | 1 | 26µs | 115µs | Data::GUID::__ANON__[:47] |
| 4 | 1 | 1 | 25µs | 25µs | main::CORE:subst (opcode) |
| 3 | 1 | 1 | 25µs | 150µs | Data::GUID::_install_as_method |
| 1 | 1 | 1 | 24µs | 297µs | Data::GUID::new |
| 1 | 1 | 1 | 23µs | 23µs | Data::GUID::BEGIN@347 |
| 2 | 2 | 1 | 22µs | 22µs | main::CORE:pack (opcode) |
| 1 | 1 | 1 | 21µs | 77µs | Data::GUID::BEGIN@215 |
| 1 | 1 | 1 | 19µs | 82µs | Data::GUID::BEGIN@196 |
| 1 | 1 | 1 | 18µs | 79µs | Data::GUID::BEGIN@282 |
| 2 | 2 | 1 | 16µs | 16µs | Data::GUID::_from_multitype |
| 1 | 1 | 1 | 13µs | 30µs | main::BEGIN@1 |
| 1 | 1 | 1 | 12µs | 12µs | main::CORE:readline (opcode) |
| 1 | 1 | 1 | 10µs | 27µs | Data::GUID::BEGIN@116 |
| 1 | 1 | 1 | 10µs | 15µs | main::BEGIN@2.1 |
| 1 | 1 | 1 | 8µs | 8µs | Data::GUID::from_data_uuid |
| 5 | 3 | 1 | 7µs | 7µs | Data::GUID::CORE:qr (opcode) |
| 1 | 1 | 1 | 5µs | 5µs | Data::GUID::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:118] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:134] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:181] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:283] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:335] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:342] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:343] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:349] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__ANON__[:356] |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::__type_regex |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::_curry_class |
| 0 | 0 | 0 | 0s | 0s | Data::GUID::compare_to_guid |
| 0 | 0 | 0 | 0s | 0s | main::RUNTIME |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 29µs | 2 | 46µs | # spent 30µs (13+16) within main::BEGIN@1 which was called:
# once (13µs+16µs) by main::BEGIN@8 at line 1 # spent 30µs making 1 call to main::BEGIN@1
# spent 16µs making 1 call to strict::import |
| 2 | 2 | 48µs | 2 | 21µs | # spent 15µs (10+6) within main::BEGIN@2.1 which was called:
# once (10µs+6µs) by main::BEGIN@8 at line 2 # spent 15µs making 1 call to main::BEGIN@2.1
# spent 6µs making 1 call to warnings::import |
| 3 | package Data::GUID; | ||||
| 4 | # ABSTRACT: globally unique identifiers | ||||
| 5 | 1 | 900ns | $Data::GUID::VERSION = '0.049'; | ||
| 6 | 2 | 30µs | 1 | 5µs | # spent 5µs within Data::GUID::BEGIN@6 which was called:
# once (5µs+0s) by main::BEGIN@8 at line 6 # spent 5µs making 1 call to Data::GUID::BEGIN@6 |
| 7 | 3 | 166µs | 3 | 2.19ms | # spent 2.13ms (1.33+796µs) within Data::GUID::BEGIN@7 which was called:
# once (1.33ms+796µs) by main::BEGIN@8 at line 7 # spent 2.13ms making 1 call to Data::GUID::BEGIN@7
# spent 51µs making 1 call to Exporter::import
# spent 12µs making 1 call to UNIVERSAL::VERSION |
| 8 | 3 | 288µs | 3 | 2.03ms | # spent 2.01ms (1.69+321µs) within Data::GUID::BEGIN@8 which was called:
# once (1.69ms+321µs) by main::BEGIN@8 at line 8 # spent 2.01ms making 1 call to Data::GUID::BEGIN@8
# spent 14µs making 1 call to UNIVERSAL::VERSION
# spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:270] |
| 9 | |||||
| 10 | #pod =head1 SYNOPSIS | ||||
| 11 | #pod | ||||
| 12 | #pod use Data::GUID; | ||||
| 13 | #pod | ||||
| 14 | #pod my $guid = Data::GUID->new; | ||||
| 15 | #pod | ||||
| 16 | #pod my $string = $guid->as_string; # or "$guid" | ||||
| 17 | #pod | ||||
| 18 | #pod my $other_guid = Data::GUID->from_string($string); | ||||
| 19 | #pod | ||||
| 20 | #pod if (($guid <=> $other_guid) == 0) { | ||||
| 21 | #pod print "They're the same!\n"; | ||||
| 22 | #pod } | ||||
| 23 | #pod | ||||
| 24 | #pod =head1 DESCRIPTION | ||||
| 25 | #pod | ||||
| 26 | #pod Data::GUID provides a simple interface for generating and using globally unique | ||||
| 27 | #pod identifiers. | ||||
| 28 | #pod | ||||
| 29 | #pod =head1 GETTING A NEW GUID | ||||
| 30 | #pod | ||||
| 31 | #pod =head2 new | ||||
| 32 | #pod | ||||
| 33 | #pod my $guid = Data::GUID->new; | ||||
| 34 | #pod | ||||
| 35 | #pod This method returns a new globally unique identifier. | ||||
| 36 | #pod | ||||
| 37 | #pod =cut | ||||
| 38 | |||||
| 39 | 1 | 300ns | my $_uuid_gen_obj; | ||
| 40 | 1 | 100ns | my $_uuid_gen_pid; | ||
| 41 | my $_uuid_gen = sub { | ||||
| 42 | 2 | 11µs | return $_uuid_gen_obj if $_uuid_gen_obj | ||
| 43 | && $_uuid_gen_pid == $$; | ||||
| 44 | |||||
| 45 | 1 | 4µs | $_uuid_gen_pid = $$; | ||
| 46 | 1 | 106µs | 1 | 89µs | $_uuid_gen_obj = Data::UUID->new; # spent 89µs making 1 call to Data::UUID::new |
| 47 | 1 | 3µs | }; | ||
| 48 | |||||
| 49 | # spent 297µs (24+273) within Data::GUID::new which was called:
# once (24µs+273µs) by main::RUNTIME at line 9 of index.cgi | ||||
| 50 | 1 | 1µs | my ($class) = @_; | ||
| 51 | |||||
| 52 | 1 | 176µs | 3 | 273µs | return $class->from_data_uuid($_uuid_gen->()->create); # spent 157µs making 1 call to Data::UUID::create
# spent 107µs making 1 call to Data::GUID::__ANON__[Data/GUID.pm:47]
# spent 8µs making 1 call to Data::GUID::from_data_uuid |
| 53 | } | ||||
| 54 | |||||
| 55 | #pod =head1 GUIDS FROM EXISTING VALUES | ||||
| 56 | #pod | ||||
| 57 | #pod These method returns a new Data::GUID object for the given GUID value. In all | ||||
| 58 | #pod cases, these methods throw an exception if given invalid input. | ||||
| 59 | #pod | ||||
| 60 | #pod =head2 from_string | ||||
| 61 | #pod | ||||
| 62 | #pod my $guid = Data::GUID->from_string("B0470602-A64B-11DA-8632-93EBF1C0E05A"); | ||||
| 63 | #pod | ||||
| 64 | #pod =head2 from_hex | ||||
| 65 | #pod | ||||
| 66 | #pod # note that a hex guid is a guid string without hyphens and with a leading 0x | ||||
| 67 | #pod my $guid = Data::GUID->from_hex("0xB0470602A64B11DA863293EBF1C0E05A"); | ||||
| 68 | #pod | ||||
| 69 | #pod =head2 from_base64 | ||||
| 70 | #pod | ||||
| 71 | #pod my $guid = Data::GUID->from_base64("sEcGAqZLEdqGMpPr8cDgWg=="); | ||||
| 72 | #pod | ||||
| 73 | #pod =head2 from_data_uuid | ||||
| 74 | #pod | ||||
| 75 | #pod This method returns a new Data::GUID object if given a Data::UUID value. | ||||
| 76 | #pod Because Data::UUID values are not blessed and because Data::UUID provides no | ||||
| 77 | #pod validation method, this method will only throw an exception if the given data | ||||
| 78 | #pod is of the wrong size. | ||||
| 79 | #pod | ||||
| 80 | #pod =cut | ||||
| 81 | |||||
| 82 | # spent 8µs within Data::GUID::from_data_uuid which was called:
# once (8µs+0s) by Data::GUID::new at line 52 | ||||
| 83 | 1 | 1µs | my ($class, $value) = @_; | ||
| 84 | |||||
| 85 | 4 | 500µs | 2 | 321µs | # spent 317µs (314+3) within Data::GUID::BEGIN@85 which was called:
# once (314µs+3µs) by main::BEGIN@8 at line 85 # spent 317µs making 1 call to Data::GUID::BEGIN@85
# spent 3µs making 1 call to bytes::import |
| 86 | 1 | 400ns | Carp::croak "given value is not a valid Data::UUID value" if $length != 16; | ||
| 87 | 1 | 6µs | bless \$value => $class; | ||
| 88 | } | ||||
| 89 | |||||
| 90 | #pod =head1 IDENTIFYING GUIDS | ||||
| 91 | #pod | ||||
| 92 | #pod =head2 string_guid_regex | ||||
| 93 | #pod | ||||
| 94 | #pod =head2 hex_guid_regex | ||||
| 95 | #pod | ||||
| 96 | #pod =head2 base64_guid_regex | ||||
| 97 | #pod | ||||
| 98 | #pod These methods return regex objects that match regex strings of the appropriate | ||||
| 99 | #pod type. | ||||
| 100 | #pod | ||||
| 101 | #pod =cut | ||||
| 102 | |||||
| 103 | 1 | 200ns | my ($hex, $base64, %type); | ||
| 104 | |||||
| 105 | # spent 125µs (58+67) within Data::GUID::BEGIN@105 which was called:
# once (58µs+67µs) by main::BEGIN@8 at line 120 | ||||
| 106 | 1 | 8µs | 1 | 2µs | $hex = qr/[0-9A-F]/i; # spent 2µs making 1 call to Data::GUID::CORE:qr |
| 107 | 1 | 4µs | 1 | 1µs | $base64 = qr{[A-Z0-9+/=]}i; # spent 1µs making 1 call to Data::GUID::CORE:qr |
| 108 | |||||
| 109 | 1 | 88µs | 6 | 64µs | %type = ( # uuid_method validation_regex # spent 60µs making 3 calls to Data::GUID::CORE:regcomp, avg 20µs/call
# spent 4µs making 3 calls to Data::GUID::CORE:qr, avg 1µs/call |
| 110 | string => [ 'string', qr/\A$hex{8}-?(?:$hex{4}-?){3}$hex{12}\z/, ], | ||||
| 111 | hex => [ 'hexstring', qr/\A0x$hex{32}\z/, ], | ||||
| 112 | base64 => [ 'b64string', qr/\A$base64{24}\z/, ], | ||||
| 113 | ); | ||||
| 114 | |||||
| 115 | 1 | 16µs | for my $key (keys %type) { | ||
| 116 | 2 | 72µs | 2 | 44µs | # spent 27µs (10+17) within Data::GUID::BEGIN@116 which was called:
# once (10µs+17µs) by main::BEGIN@8 at line 116 # spent 27µs making 1 call to Data::GUID::BEGIN@116
# spent 17µs making 1 call to strict::unimport |
| 117 | 3 | 3µs | my $subname = "$key\_guid_regex"; | ||
| 118 | *$subname = sub { $type{ $key }[1] } | ||||
| 119 | 3 | 14µs | } | ||
| 120 | 1 | 379µs | 1 | 125µs | } # spent 125µs making 1 call to Data::GUID::BEGIN@105 |
| 121 | |||||
| 122 | # provided for test scripts | ||||
| 123 | sub __type_regex { shift; $type{$_[0]}[1] } | ||||
| 124 | |||||
| 125 | # spent 171µs (32+139) within Data::GUID::_install_from_method which was called 3 times, avg 57µs/call:
# 3 times (32µs+139µs) by Data::GUID::BEGIN@152 at line 155, avg 57µs/call | ||||
| 126 | 3 | 2µs | my ($type, $alien_method, $regex) = @_; | ||
| 127 | 3 | 2µs | my $alien_from_method = "from_$alien_method"; | ||
| 128 | |||||
| 129 | my $our_from_code = sub { | ||||
| 130 | my ($class, $string) = @_; | ||||
| 131 | $string ||= q{}; # to avoid (undef =~) warning | ||||
| 132 | Carp::croak qq{"$string" is not a valid $type GUID} if $string !~ $regex; | ||||
| 133 | $class->from_data_uuid( $_uuid_gen->()->$alien_from_method($string) ); | ||||
| 134 | 3 | 13µs | }; | ||
| 135 | |||||
| 136 | 3 | 15µs | 3 | 139µs | Sub::Install::install_sub({ code => $our_from_code, as => "from_$type" }); # spent 139µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 46µs/call |
| 137 | } | ||||
| 138 | |||||
| 139 | # spent 150µs (25+125) within Data::GUID::_install_as_method which was called 3 times, avg 50µs/call:
# 3 times (25µs+125µs) by Data::GUID::BEGIN@152 at line 156, avg 50µs/call | ||||
| 140 | 3 | 2µs | my ($type, $alien_method) = @_; | ||
| 141 | |||||
| 142 | 3 | 2µs | my $alien_to_method = "to_$alien_method"; | ||
| 143 | |||||
| 144 | # spent 112µs (70+42) within Data::GUID::__ANON__[/usr/local/share/perl/5.18.2/Data/GUID.pm:147] which was called:
# once (70µs+42µs) by main::RUNTIME at line 10 of index.cgi | ||||
| 145 | 1 | 300ns | my ($self) = @_; | ||
| 146 | 1 | 74µs | 3 | 42µs | $_uuid_gen->()->$alien_to_method( $self->as_binary ); # spent 28µs making 1 call to Data::GUID::as_binary
# spent 7µs making 1 call to Data::GUID::__ANON__[Data/GUID.pm:47]
# spent 7µs making 1 call to Data::UUID::to_string |
| 147 | 3 | 7µs | }; | ||
| 148 | |||||
| 149 | 3 | 13µs | 3 | 125µs | Sub::Install::install_sub({ code => $our_to_method, as => "as_$type" }); # spent 125µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 42µs/call |
| 150 | } | ||||
| 151 | |||||
| 152 | # spent 357µs (36+321) within Data::GUID::BEGIN@152 which was called:
# once (36µs+321µs) by main::BEGIN@8 at line 159 | ||||
| 153 | 1 | 4µs | do { | ||
| 154 | 1 | 12µs | while (my ($type, $profile) = each %type) { | ||
| 155 | 3 | 8µs | 3 | 171µs | _install_from_method($type, @$profile); # spent 171µs making 3 calls to Data::GUID::_install_from_method, avg 57µs/call |
| 156 | 3 | 6µs | 3 | 150µs | _install_as_method ($type, @$profile); # spent 150µs making 3 calls to Data::GUID::_install_as_method, avg 50µs/call |
| 157 | } | ||||
| 158 | }; | ||||
| 159 | 1 | 272µs | 1 | 357µs | } # spent 357µs making 1 call to Data::GUID::BEGIN@152 |
| 160 | |||||
| 161 | sub _from_multitype { | ||||
| 162 | 2 | 2µs | my ($class, $what, $types) = @_; | ||
| 163 | sub { | ||||
| 164 | my ($class, $value) = @_; | ||||
| 165 | return $value if eval { $value->isa('Data::GUID') }; | ||||
| 166 | |||||
| 167 | my $value_string = defined $value ? qq{"$value"} : 'undef'; | ||||
| 168 | |||||
| 169 | # The only good ref is a blessed ref, and only into our denomination! | ||||
| 170 | if (my $ref = ref $value) { | ||||
| 171 | Carp::croak "a $ref reference is not a valid GUID $what" | ||||
| 172 | } | ||||
| 173 | |||||
| 174 | for my $type (@$types) { | ||||
| 175 | my $from = "from_$type"; | ||||
| 176 | my $guid = eval { $class->$from($value); }; | ||||
| 177 | return $guid if $guid; | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | Carp::croak "$value_string is not a valid GUID $what"; | ||||
| 181 | } | ||||
| 182 | 2 | 28µs | } | ||
| 183 | |||||
| 184 | #pod =head2 from_any_string | ||||
| 185 | #pod | ||||
| 186 | #pod my $string = get_string_from_ether; | ||||
| 187 | #pod | ||||
| 188 | #pod my $guid = Data::GUID->from_any_string($string); | ||||
| 189 | #pod | ||||
| 190 | #pod This method returns a Data::GUID object for the given string, trying all known | ||||
| 191 | #pod string interpretations. An exception is thrown if the value is not a valid | ||||
| 192 | #pod GUID string. | ||||
| 193 | #pod | ||||
| 194 | #pod =cut | ||||
| 195 | |||||
| 196 | # spent 82µs (19+62) within Data::GUID::BEGIN@196 which was called:
# once (19µs+62µs) by main::BEGIN@8 at line 201 | ||||
| 197 | 1 | 10µs | 2 | 62µs | Sub::Install::install_sub({ # spent 52µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:118]
# spent 11µs making 1 call to Data::GUID::_from_multitype |
| 198 | code => __PACKAGE__->_from_multitype('string', [ keys %type ]), | ||||
| 199 | as => 'from_any_string', | ||||
| 200 | }); | ||||
| 201 | 1 | 95µs | 1 | 82µs | } # spent 82µs making 1 call to Data::GUID::BEGIN@196 |
| 202 | |||||
| 203 | #pod =head2 best_guess | ||||
| 204 | #pod | ||||
| 205 | #pod my $value = get_value_from_ether; | ||||
| 206 | #pod | ||||
| 207 | #pod my $guid = Data::GUID->best_guess($value); | ||||
| 208 | #pod | ||||
| 209 | #pod This method returns a Data::GUID object for the given value, trying everything | ||||
| 210 | #pod it can. It works like C<L</from_any_string>>, but will also accept Data::UUID | ||||
| 211 | #pod values. (In effect, this means that any sixteen byte value is acceptable.) | ||||
| 212 | #pod | ||||
| 213 | #pod =cut | ||||
| 214 | |||||
| 215 | # spent 77µs (21+55) within Data::GUID::BEGIN@215 which was called:
# once (21µs+55µs) by main::BEGIN@8 at line 220 | ||||
| 216 | 1 | 9µs | 2 | 55µs | Sub::Install::install_sub({ # spent 50µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:118]
# spent 6µs making 1 call to Data::GUID::_from_multitype |
| 217 | code => __PACKAGE__->_from_multitype('value', [(keys %type), 'data_uuid']), | ||||
| 218 | as => 'best_guess', | ||||
| 219 | }); | ||||
| 220 | 1 | 219µs | 1 | 77µs | } # spent 77µs making 1 call to Data::GUID::BEGIN@215 |
| 221 | |||||
| 222 | #pod =head1 GUIDS INTO STRINGS | ||||
| 223 | #pod | ||||
| 224 | #pod These methods return various string representations of a GUID. | ||||
| 225 | #pod | ||||
| 226 | #pod =head2 as_string | ||||
| 227 | #pod | ||||
| 228 | #pod This method returns a "traditional" GUID/UUID string representation. This is | ||||
| 229 | #pod five hexadecimal strings, delimited by hyphens. For example: | ||||
| 230 | #pod | ||||
| 231 | #pod B0470602-A64B-11DA-8632-93EBF1C0E05A | ||||
| 232 | #pod | ||||
| 233 | #pod This method is also used to stringify Data::GUID objects. | ||||
| 234 | #pod | ||||
| 235 | #pod =head2 as_hex | ||||
| 236 | #pod | ||||
| 237 | #pod This method returns a plain hexadecimal representation of the GUID, with a | ||||
| 238 | #pod leading C<0x>. For example: | ||||
| 239 | #pod | ||||
| 240 | #pod 0xB0470602A64B11DA863293EBF1C0E05A | ||||
| 241 | #pod | ||||
| 242 | #pod =head2 as_base64 | ||||
| 243 | #pod | ||||
| 244 | #pod This method returns a base-64 string representation of the GUID. For example: | ||||
| 245 | #pod | ||||
| 246 | #pod sEcGAqZLEdqGMpPr8cDgWg== | ||||
| 247 | #pod | ||||
| 248 | #pod =cut | ||||
| 249 | |||||
| 250 | #pod =head1 OTHER METHODS | ||||
| 251 | #pod | ||||
| 252 | #pod =head2 compare_to_guid | ||||
| 253 | #pod | ||||
| 254 | #pod This method compares a GUID to another GUID and returns -1, 0, or 1, as do | ||||
| 255 | #pod other comparison routines. | ||||
| 256 | #pod | ||||
| 257 | #pod =cut | ||||
| 258 | |||||
| 259 | sub compare_to_guid { | ||||
| 260 | my ($self, $other) = @_; | ||||
| 261 | |||||
| 262 | my $other_binary | ||||
| 263 | = eval { $other->isa('Data::GUID') } ? $other->as_binary : $other; | ||||
| 264 | |||||
| 265 | $_uuid_gen->()->compare($self->as_binary, $other_binary); | ||||
| 266 | } | ||||
| 267 | |||||
| 268 | #pod =head2 as_binary | ||||
| 269 | #pod | ||||
| 270 | #pod This method returns the packed binary representation of the GUID. At present | ||||
| 271 | #pod this method relies on Data::GUID's underlying use of Data::UUID. It is not | ||||
| 272 | #pod guaranteed to continue to work the same way, or at all. I<Caveat invocator>. | ||||
| 273 | #pod | ||||
| 274 | #pod =cut | ||||
| 275 | |||||
| 276 | # spent 28µs within Data::GUID::as_binary which was called:
# once (28µs+0s) by Data::GUID::__ANON__[/usr/local/share/perl/5.18.2/Data/GUID.pm:147] at line 146 | ||||
| 277 | 1 | 400ns | my ($self) = @_; | ||
| 278 | 1 | 30µs | $$self; | ||
| 279 | } | ||||
| 280 | |||||
| 281 | use overload | ||||
| 282 | # spent 79µs (18+61) within Data::GUID::BEGIN@282 which was called:
# once (18µs+61µs) by main::BEGIN@8 at line 284 | ||||
| 283 | '<=>' => sub { ($_[2] ? -1 : 1) * $_[0]->compare_to_guid($_[1]) }, | ||||
| 284 | 2 | 206µs | 2 | 140µs | fallback => 1; # spent 79µs making 1 call to Data::GUID::BEGIN@282
# spent 61µs making 1 call to overload::import |
| 285 | |||||
| 286 | #pod =head1 IMPORTING | ||||
| 287 | #pod | ||||
| 288 | #pod Data::GUID does not export any subroutines by default, but it provides a few | ||||
| 289 | #pod routines which will be imported on request. These routines may be called as | ||||
| 290 | #pod class methods, or may be imported to be called as subroutines. Calling them by | ||||
| 291 | #pod fully qualified name is incorrect. | ||||
| 292 | #pod | ||||
| 293 | #pod use Data::GUID qw(guid); | ||||
| 294 | #pod | ||||
| 295 | #pod my $guid = guid; # OK | ||||
| 296 | #pod my $guid = Data::GUID->guid; # OK | ||||
| 297 | #pod my $guid = Data::GUID::guid; # NOT OK | ||||
| 298 | #pod | ||||
| 299 | #pod =cut | ||||
| 300 | |||||
| 301 | #pod =head2 guid | ||||
| 302 | #pod | ||||
| 303 | #pod This routine returns a new Data::GUID object. | ||||
| 304 | #pod | ||||
| 305 | #pod =head2 guid_string | ||||
| 306 | #pod | ||||
| 307 | #pod This returns the string representation of a new GUID. | ||||
| 308 | #pod | ||||
| 309 | #pod =head2 guid_hex | ||||
| 310 | #pod | ||||
| 311 | #pod This returns the hex representation of a new GUID. | ||||
| 312 | #pod | ||||
| 313 | #pod =head2 guid_base64 | ||||
| 314 | #pod | ||||
| 315 | #pod This returns the base64 representation of a new GUID. | ||||
| 316 | #pod | ||||
| 317 | #pod =head2 guid_from_anything | ||||
| 318 | #pod | ||||
| 319 | #pod This returns the result of calling the C<L</from_any_string>> method. | ||||
| 320 | #pod | ||||
| 321 | #pod =cut | ||||
| 322 | |||||
| 323 | # spent 336µs (50+286) within Data::GUID::BEGIN@323 which was called:
# once (50µs+286µs) by main::BEGIN@8 at line 338 | ||||
| 324 | 1 | 12µs | 1 | 146µs | Sub::Install::install_sub({ code => 'new', as => 'guid' }); # spent 146µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:118] |
| 325 | |||||
| 326 | 1 | 6µs | for my $type (keys %type) { | ||
| 327 | 3 | 4µs | my $method = "guid_$type"; | ||
| 328 | 3 | 2µs | my $as = "as_$type"; | ||
| 329 | |||||
| 330 | Sub::Install::install_sub({ | ||||
| 331 | as => $method, | ||||
| 332 | code => sub { | ||||
| 333 | my ($class) = @_; | ||||
| 334 | $class->new->$as; | ||||
| 335 | }, | ||||
| 336 | 3 | 21µs | 3 | 140µs | }); # spent 140µs making 3 calls to Sub::Install::__ANON__[Sub/Install.pm:118], avg 47µs/call |
| 337 | } | ||||
| 338 | 1 | 229µs | 1 | 336µs | } # spent 336µs making 1 call to Data::GUID::BEGIN@323 |
| 339 | |||||
| 340 | sub _curry_class { | ||||
| 341 | my ($class, $subname, $eval) = @_; | ||||
| 342 | return $eval ? sub { eval { $class->$subname(@_) } } | ||||
| 343 | : sub { $class->$subname(@_) }; | ||||
| 344 | } | ||||
| 345 | |||||
| 346 | my %exports; | ||||
| 347 | # spent 23µs within Data::GUID::BEGIN@347 which was called:
# once (23µs+0s) by main::BEGIN@8 at line 351 | ||||
| 348 | 4 | 2µs | %exports | ||
| 349 | 4 | 8µs | = map { my $method = $_; $_ => sub { _curry_class($_[0], $method) } } | ||
| 350 | 1 | 14µs | ((map { "guid_$_" } keys %type), 'guid'); | ||
| 351 | 1 | 75µs | 1 | 23µs | } # spent 23µs making 1 call to Data::GUID::BEGIN@347 |
| 352 | |||||
| 353 | # spent 8.07ms (3.30+4.77) within Data::GUID::BEGIN@353 which was called:
# once (3.30ms+4.77ms) by main::BEGIN@8 at line 358 | ||||
| 354 | exports => { | ||||
| 355 | %exports, # defined just above | ||||
| 356 | guid_from_anything => sub { _curry_class($_[0], 'from_any_string', 1) }, | ||||
| 357 | } | ||||
| 358 | 3 | 154µs | 3 | 8.57ms | }; # spent 8.07ms making 1 call to Data::GUID::BEGIN@353
# spent 490µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
# spent 12µs making 1 call to UNIVERSAL::VERSION |
| 359 | |||||
| 360 | #pod =head1 TODO | ||||
| 361 | #pod | ||||
| 362 | #pod =for :list | ||||
| 363 | #pod * add namespace support | ||||
| 364 | #pod * remove dependency on wretched Data::UUID | ||||
| 365 | #pod * make it work on 5.005 | ||||
| 366 | #pod | ||||
| 367 | #pod =cut | ||||
| 368 | |||||
| 369 | 1 | 5µs | 1; | ||
| 370 | |||||
| 371 | __END__ | ||||
sub Data::GUID::CORE:qr; # opcode | |||||
# spent 60µs within Data::GUID::CORE:regcomp which was called 3 times, avg 20µs/call:
# 3 times (60µs+0s) by Data::GUID::BEGIN@105 at line 109, avg 20µs/call | |||||
# spent 38µs within main::CORE:close which was called:
# once (38µs+0s) by main::RUNTIME at line 66 of index.cgi | |||||
# spent 330µs within main::CORE:open which was called 2 times, avg 165µs/call:
# once (312µs+0s) by main::RUNTIME at line 64 of index.cgi
# once (18µs+0s) by main::RUNTIME at line 70 of index.cgi | |||||
# spent 22µs within main::CORE:pack which was called 2 times, avg 11µs/call:
# once (20µs+0s) by String::Markov::BEGIN@11 at line 4 of Unicode/Normalize.pm
# once (2µs+0s) by String::Markov::BEGIN@11 at line 45 of Unicode/Normalize.pm | |||||
# spent 1.51ms within main::CORE:print which was called 2 times, avg 753µs/call:
# once (1.32ms+0s) by main::RUNTIME at line 71 of index.cgi
# once (188µs+0s) by main::RUNTIME at line 13 of index.cgi | |||||
# spent 12µs within main::CORE:readline which was called:
# once (12µs+0s) by main::RUNTIME at line 71 of index.cgi | |||||
# spent 25µs within main::CORE:subst which was called 4 times, avg 6µs/call:
# 4 times (25µs+0s) by main::RUNTIME at line 56 of index.cgi, avg 6µs/call | |||||
# spent 103µs within main::CORE:syswrite which was called:
# once (103µs+0s) by main::RUNTIME at line 65 of index.cgi |