← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:39:01 2010
Reported on Wed Nov 17 22:04:58 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Data/UUID/LibUUID.pm
StatementsExecuted 23 statements in 2.61ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.07ms3.71msData::UUID::LibUUID::::BEGIN@11Data::UUID::LibUUID::BEGIN@11
11189µs107µsData::UUID::LibUUID::::BEGIN@5Data::UUID::LibUUID::BEGIN@5
11173µs2.31msData::UUID::LibUUID::::BEGIN@13Data::UUID::LibUUID::BEGIN@13
11138µs226µsData::UUID::LibUUID::::BEGIN@7Data::UUID::LibUUID::BEGIN@7
0000s0sData::UUID::LibUUID::::ascending_identData::UUID::LibUUID::ascending_ident
0000s0sData::UUID::LibUUID::::uuid_to_base64Data::UUID::LibUUID::uuid_to_base64
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#!/usr/bin/perl
2
3package Data::UUID::LibUUID;
4
53140µs2125µs
# spent 107µs (89+18) within Data::UUID::LibUUID::BEGIN@5 which was called: # once (89µs+18µs) by KiokuDB::Role::UUIDs::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/Role/UUIDs.pm:13] at line 5
use strict;
# spent 107µs making 1 call to Data::UUID::LibUUID::BEGIN@5 # spent 18µs making 1 call to strict::import
6
73131µs2413µs
# spent 226µs (38+187) within Data::UUID::LibUUID::BEGIN@7 which was called: # once (38µs+187µs) by KiokuDB::Role::UUIDs::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/Role/UUIDs.pm:13] at line 7
use vars qw($VERSION @ISA);
# spent 226µs making 1 call to Data::UUID::LibUUID::BEGIN@7 # spent 187µs making 1 call to vars::import
8
914µs$VERSION = '0.05';
10
113515µs13.71ms
# spent 3.71ms (2.07+1.64) within Data::UUID::LibUUID::BEGIN@11 which was called: # once (2.07ms+1.64ms) by KiokuDB::Role::UUIDs::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/Role/UUIDs.pm:13] at line 11
use Time::HiRes ();
# spent 3.71ms making 1 call to Data::UUID::LibUUID::BEGIN@11
12
1312.24ms
# spent 2.31ms (73µs+2.24) within Data::UUID::LibUUID::BEGIN@13 which was called: # once (73µs+2.24ms) by KiokuDB::Role::UUIDs::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/Role/UUIDs.pm:13] at line 30
use Sub::Exporter -setup => {
# spent 2.24ms making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
14 exports => [qw(
15 new_uuid_string new_uuid_binary
16
17 uuid_to_binary uuid_to_string uuid_to_hex uuid_to_base64
18
19 uuid_eq uuid_compare
20
21 new_dce_uuid_string new_dce_uuid_binary
22
23 new_uuid_str new_uuid_bin new_dce_uuid_bin new_dce_uuid_str
24
25 ascending_ident
26 )],
27 groups => {
28 default => [qw(new_uuid_string new_uuid_binary uuid_eq)],
29 },
303886µs12.31ms};
# spent 2.31ms making 1 call to Data::UUID::LibUUID::BEGIN@13
31
32eval {
3314µs require XSLoader;
341857µs1823µs XSLoader::load('Data::UUID::LibUUID', $VERSION);
# spent 823µs making 1 call to XSLoader::load
3515µs 1;
3615µs} or do {
37 require DynaLoader;
38 push @ISA, 'DynaLoader';
39 bootstrap Data::UUID::LibUUID $VERSION;
40};
41
42# convenient aliases
4317µs*new_dce_uuid_bin = \&new_dce_uuid_binary;
4414µs*new_uuid_bin = \&new_uuid_binary;
4514µs*new_dce_uuid_str = \&new_dce_uuid_string;
4613µs*new_uuid_str = \&new_uuid_string;
47
48sub uuid_to_base64 {
49 require MIME::Base64;
50 MIME::Base64::encode_base64(uuid_to_binary($_[0]), '');
51}
52
5314µsmy ( $last_s, $last_us, $i ) = ( 0, 0 );
54sub ascending_ident {
55 my ( $s, $us ) = Time::HiRes::gettimeofday;
56
57 # usec is at most 20 bits (log 2 of 1 million), so we truncate the bottom 4
58 # and use only 16 bits, with 16 more bits for a counter. decent hardware
59 # can generate several of these per usec, bot not 65 thousand per 16 usecs =)
60
61 # without $i but with a full 20 bits identifiers would be merely
62 # monotonically increasing
63
64 my $trunc_us = $us >> 4;
65
66 if ( $last_us != $trunc_us or $last_s != $s ) {
67 # the timer has increased, we can reset the counter
68 $i = 0;
69 $last_us = $trunc_us;
70 $last_s = $s;
71 } else {
72 # increment the timer, but truncate it to 16 bits
73
74 # i've never seen it actually bigger than 2 so that gives a margin of
75 # about 5 orders of magnitude. Hopefully Moore's law doesn't get me ;-)
76
77 $i = $i+1 % 0xffff;
78 }
79
80 unpack("H*",pack("Nnn", $s, $trunc_us, $i)) . '-' . new_uuid_string();
81}
82
83137µs__PACKAGE__
84
85__END__