← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:34 2011

Filename/usr/lib/perl/5.14/Digest/SHA.pm
StatementsExecuted 23 statements in 2.02ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111196µs196µsDigest::SHA::::bootstrapDigest::SHA::bootstrap (xsub)
11150µs219µsDigest::SHA::::BEGIN@6Digest::SHA::BEGIN@6
11126µs34µsDigest::SHA::::BEGIN@5Digest::SHA::BEGIN@5
11121µs1.01msDigest::SHA::::BEGIN@7Digest::SHA::BEGIN@7
11117µs23µsDigest::SHA::::BEGIN@8Digest::SHA::BEGIN@8
0000s0sDigest::SHA::::AddfileDigest::SHA::Addfile
0000s0sDigest::SHA::::DESTROYDigest::SHA::DESTROY
0000s0sDigest::SHA::::_addfileDigest::SHA::_addfile
0000s0sDigest::SHA::::_bailDigest::SHA::_bail
0000s0sDigest::SHA::::add_bitsDigest::SHA::add_bits
0000s0sDigest::SHA::::cloneDigest::SHA::clone
0000s0sDigest::SHA::::dumpDigest::SHA::dump
0000s0sDigest::SHA::::loadDigest::SHA::load
0000s0sDigest::SHA::::newDigest::SHA::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Digest::SHA;
2
3123µsrequire 5.003000;
4
5259µs242µs
# spent 34µs (26+8) within Digest::SHA::BEGIN@5 which was called: # once (26µs+8µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 5
use strict;
# spent 34µs making 1 call to Digest::SHA::BEGIN@5 # spent 8µs making 1 call to strict::import
6281µs2388µs
# spent 219µs (50+169) within Digest::SHA::BEGIN@6 which was called: # once (50µs+169µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 6
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
# spent 219µs making 1 call to Digest::SHA::BEGIN@6 # spent 169µs making 1 call to vars::import
7245µs22.01ms
# spent 1.01ms (21µs+992µs) within Digest::SHA::BEGIN@7 which was called: # once (21µs+992µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 7
use Fcntl;
# spent 1.01ms making 1 call to Digest::SHA::BEGIN@7 # spent 992µs making 1 call to Exporter::import
821.46ms230µs
# spent 23µs (17+6) within Digest::SHA::BEGIN@8 which was called: # once (17µs+6µs) by Foswiki::Users::HtPasswdUser::BEGIN@2 at line 8
use integer;
# spent 23µs making 1 call to Digest::SHA::BEGIN@8 # spent 6µs making 1 call to integer::import
9
1012µs$VERSION = '5.61';
11
1212µsrequire Exporter;
131137µsrequire DynaLoader;
14112µs@ISA = qw(Exporter DynaLoader);
1519µs@EXPORT_OK = qw(
16 hmac_sha1 hmac_sha1_base64 hmac_sha1_hex
17 hmac_sha224 hmac_sha224_base64 hmac_sha224_hex
18 hmac_sha256 hmac_sha256_base64 hmac_sha256_hex
19 hmac_sha384 hmac_sha384_base64 hmac_sha384_hex
20 hmac_sha512 hmac_sha512_base64 hmac_sha512_hex
21 hmac_sha512224 hmac_sha512224_base64 hmac_sha512224_hex
22 hmac_sha512256 hmac_sha512256_base64 hmac_sha512256_hex
23 sha1 sha1_base64 sha1_hex
24 sha224 sha224_base64 sha224_hex
25 sha256 sha256_base64 sha256_hex
26 sha384 sha384_base64 sha384_hex
27 sha512 sha512_base64 sha512_hex
28 sha512224 sha512224_base64 sha512224_hex
29 sha512256 sha512256_base64 sha512256_hex);
30
31# If possible, inherit from Digest::base (which depends on MIME::Base64)
32
3313µs*addfile = \&Addfile;
34
3513µseval {
361126µs require MIME::Base64;
3712µs require Digest::base;
38113µs push(@ISA, 'Digest::base');
39};
4011µsif ($@) {
41 *hexdigest = \&Hexdigest;
42 *b64digest = \&B64digest;
43}
44
45# The following routines aren't time-critical, so they can be left in Perl
46
47sub new {
48 my($class, $alg) = @_;
49 $alg =~ s/\D+//g if defined $alg;
50 if (ref($class)) { # instance method
51 unless (defined($alg) && ($alg != $class->algorithm)) {
52 sharewind($$class);
53 return($class);
54 }
55 shaclose($$class) if $$class;
56 $$class = shaopen($alg) || return;
57 return($class);
58 }
59 $alg = 1 unless defined $alg;
60 my $state = shaopen($alg) || return;
61 my $self = \$state;
62 bless($self, $class);
63 return($self);
64}
65
66sub DESTROY {
67 my $self = shift;
68 shaclose($$self) if $$self;
69}
70
71sub clone {
72 my $self = shift;
73 my $state = shadup($$self) || return;
74 my $copy = \$state;
75 bless($copy, ref($self));
76 return($copy);
77}
78
7912µs*reset = \&new;
80
81sub add_bits {
82 my($self, $data, $nbits) = @_;
83 unless (defined $nbits) {
84 $nbits = length($data);
85 $data = pack("B*", $data);
86 }
87 shawrite($data, $nbits, $$self);
88 return($self);
89}
90
91sub _bail {
92 my $msg = shift;
93
94 require Carp;
95 Carp::croak("$msg: $!");
96}
97
98sub _addfile { # this is "addfile" from Digest::base 1.00
99 my ($self, $handle) = @_;
100
101 my $n;
102 my $buf = "";
103
104 while (($n = read($handle, $buf, 4096))) {
105 $self->add($buf);
106 }
107 _bail("Read failed") unless defined $n;
108
109 $self;
110}
111
112sub Addfile {
113 my ($self, $file, $mode) = @_;
114
115 return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR';
116
117 $mode = defined($mode) ? $mode : "";
118 my ($binary, $portable) = map { $_ eq $mode } ("b", "p");
119
120 ## Always interpret "-" to mean STDIN; otherwise use
121 ## sysopen to handle full range of POSIX file names
122 local *FH;
123 $file eq '-' and open(FH, '< -')
124 or sysopen(FH, $file, O_RDONLY)
125 or _bail('Open failed');
126 binmode(FH) if $binary || $portable;
127
128 unless ($portable && -T $file) {
129 $self->_addfile(*FH);
130 close(FH);
131 return($self);
132 }
133
134 my ($n1, $n2);
135 my ($buf1, $buf2) = ("", "");
136
137 while (($n1 = read(FH, $buf1, 4096))) {
138 while (substr($buf1, -1) eq "\015") {
139 $n2 = read(FH, $buf2, 4096);
140 _bail("Read failed") unless defined $n2;
141 last unless $n2;
142 $buf1 .= $buf2;
143 }
144 $buf1 =~ s/\015?\015\012/\012/g; # DOS/Windows
145 $buf1 =~ s/\015/\012/g; # early MacOS
146 $self->add($buf1);
147 }
148 _bail("Read failed") unless defined $n1;
149 close(FH);
150
151 $self;
152}
153
154sub dump {
155 my $self = shift;
156 my $file = shift || "";
157
158 shadump($file, $$self) || return;
159 return($self);
160}
161
162sub load {
163 my $class = shift;
164 my $file = shift || "";
165 if (ref($class)) { # instance method
166 shaclose($$class) if $$class;
167 $$class = shaload($file) || return;
168 return($class);
169 }
170 my $state = shaload($file) || return;
171 my $self = \$state;
172 bless($self, $class);
173 return($self);
174}
175
176114µs1562µsDigest::SHA->bootstrap($VERSION);
# spent 562µs making 1 call to DynaLoader::bootstrap
177
178128µs1;
179__END__
 
# spent 196µs within Digest::SHA::bootstrap which was called: # once (196µs+0s) by DynaLoader::bootstrap at line 207 of DynaLoader.pm
sub Digest::SHA::bootstrap; # xsub