Profile of Digest/base.pm

← Index
NYTProf Performance Profile «line view»
For t/bug-md-11.t
Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/5.38.2/Digest/base.pm
Statements | Executed 6 statements in 246µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 10µs | 12µs | Digest::base::::BEGIN@3Digest::base::BEGIN@3
1 | 1 | 1 | 4µs | 20µs | Digest::base::::BEGIN@4Digest::base::BEGIN@4
0 | 0 | 0 | 0s | 0s | Digest::base::::add_bitsDigest::base::add_bits
0 | 0 | 0 | 0s | 0s | Digest::base::::addfileDigest::base::addfile
0 | 0 | 0 | 0s | 0s | Digest::base::::b64digestDigest::base::b64digest
0 | 0 | 0 | 0s | 0s | Digest::base::::base64_padded_digestDigest::base::base64_padded_digest
0 | 0 | 0 | 0s | 0s | Digest::base::::hexdigestDigest::base::hexdigest
0 | 0 | 0 | 0s | 0s | Digest::base::::resetDigest::base::reset

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

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Digest::base;
2 |  |  |  |  |
3 | 2 | 20µs | 2 | 13µs | # spent 12µs (10+1) within Digest::base::BEGIN@3 which was called: # once (10µs+1µs) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@12 at line 3 use strict; # spent 12µs making 1 call to Digest::base::BEGIN@3 # spent 2µs making 1 call to strict::import
4 | 2 | 223µs | 2 | 36µs | # spent 20µs (4+16) within Digest::base::BEGIN@4 which was called: # once (4µs+16µs) by Spreadsheet::ParseXLSX::Decryptor::BEGIN@12 at line 4 use warnings; # spent 20µs making 1 call to Digest::base::BEGIN@4 # spent 16µs making 1 call to warnings::import
5 |  |  |  |  |
6 | 1 | 300ns |  |  | our $VERSION = "1.20";
7 |  |  |  |  |
8 |  |  |  |  | # subclass is supposed to implement at least these
9 |  |  |  |  | sub new;
10 |  |  |  |  | sub clone;
11 |  |  |  |  | sub add;
12 |  |  |  |  | sub digest;
13 |  |  |  |  |
14 |  |  |  |  | sub reset {
15 |  |  |  |  | my $self = shift;
16 |  |  |  |  | $self->new(@_); # ugly
17 |  |  |  |  | }
18 |  |  |  |  |
19 |  |  |  |  | sub addfile {
20 |  |  |  |  | my ( $self, $handle ) = @_;
21 |  |  |  |  |
22 |  |  |  |  | my $n;
23 |  |  |  |  | my $buf = "";
24 |  |  |  |  |
25 |  |  |  |  | while ( ( $n = read( $handle, $buf, 4 * 1024 ) ) ) {
26 |  |  |  |  | $self->add($buf);
27 |  |  |  |  | }
28 |  |  |  |  | unless ( defined $n ) {
29 |  |  |  |  | require Carp;
30 |  |  |  |  | Carp::croak("Read failed: $!");
31 |  |  |  |  | }
32 |  |  |  |  |
33 |  |  |  |  | $self;
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | sub add_bits {
37 |  |  |  |  | my $self = shift;
38 |  |  |  |  | my $bits;
39 |  |  |  |  | my $nbits;
40 |  |  |  |  | if ( @_ == 1 ) {
41 |  |  |  |  | my $arg = shift;
42 |  |  |  |  | $bits = pack( "B*", $arg );
43 |  |  |  |  | $nbits = length($arg);
44 |  |  |  |  | }
45 |  |  |  |  | else {
46 |  |  |  |  | ( $bits, $nbits ) = @_;
47 |  |  |  |  | }
48 |  |  |  |  | if ( ( $nbits % 8 ) != 0 ) {
49 |  |  |  |  | require Carp;
50 |  |  |  |  | Carp::croak("Number of bits must be multiple of 8 for this algorithm");
51 |  |  |  |  | }
52 |  |  |  |  | return $self->add( substr( $bits, 0, $nbits / 8 ) );
53 |  |  |  |  | }
54 |  |  |  |  |
55 |  |  |  |  | sub hexdigest {
56 |  |  |  |  | my $self = shift;
57 |  |  |  |  | return unpack( "H*", $self->digest(@_) );
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | sub b64digest {
61 |  |  |  |  | my $self = shift;
62 |  |  |  |  | my $b64 = $self->base64_padded_digest;
63 |  |  |  |  | $b64 =~ s/=+$//;
64 |  |  |  |  | return $b64;
65 |  |  |  |  | }
66 |  |  |  |  |
67 |  |  |  |  | sub base64_padded_digest {
68 |  |  |  |  | my $self = shift;
69 |  |  |  |  | require MIME::Base64;
70 |  |  |  |  | return MIME::Base64::encode( $self->digest(@_), "" );
71 |  |  |  |  | }
72 |  |  |  |  |
73 | 1 | 2µs |  |  | 1;
74 |  |  |  |  |
75 |  |  |  |  | __END__