← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:31:39 2016

Filename/usr/share/perl/5.20/File/Compare.pm
StatementsExecuted 79 statements in 955µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21190µs157µsFile::Compare::::compareFile::Compare::compare
42133µs33µsFile::Compare::::CORE:openFile::Compare::CORE:open (opcode)
11124µs24µsFile::Compare::::BEGIN@3File::Compare::BEGIN@3
63120µs20µsFile::Compare::::CORE:readFile::Compare::CORE:read (opcode)
11112µs18µsFile::Compare::::BEGIN@5File::Compare::BEGIN@5
1119µs18µsFile::Compare::::BEGIN@4File::Compare::BEGIN@4
4418µs8µsFile::Compare::::CORE:closeFile::Compare::CORE:close (opcode)
4213µs3µsFile::Compare::::CORE:binmodeFile::Compare::CORE:binmode (opcode)
4212µs2µsFile::Compare::::CORE:ftsizeFile::Compare::CORE:ftsize (opcode)
0000s0sFile::Compare::::compare_textFile::Compare::compare_text
0000s0sFile::Compare::::croakFile::Compare::croak
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::Compare;
2
3251µs124µs
# spent 24µs within File::Compare::BEGIN@3 which was called: # once (24µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 3
use 5.006;
# spent 24µs making 1 call to File::Compare::BEGIN@3
4236µs226µs
# spent 18µs (9+9) within File::Compare::BEGIN@4 which was called: # once (9µs+9µs) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 4
use strict;
# spent 18µs making 1 call to File::Compare::BEGIN@4 # spent 9µs making 1 call to strict::import
52690µs224µs
# spent 18µs (12+6) within File::Compare::BEGIN@5 which was called: # once (12µs+6µs) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 5
use warnings;
# spent 18µs making 1 call to File::Compare::BEGIN@5 # spent 6µs making 1 call to warnings::import
61500nsour($VERSION, @ISA, @EXPORT, @EXPORT_OK, $Too_Big);
7
811µsrequire Exporter;
9
101400ns$VERSION = '1.1006';
1118µs@ISA = qw(Exporter);
121400ns@EXPORT = qw(compare);
131400ns@EXPORT_OK = qw(cmp compare_text);
14
151200ns$Too_Big = 1024 * 1024 * 2;
16
17sub croak {
18 require Carp;
19 goto &Carp::croak;
20}
21
22
# spent 157µs (90+67) within File::Compare::compare which was called 2 times, avg 78µs/call: # 2 times (90µs+67µs) by File::Find::find at line 99 of DateTime/TimeZone/Local/Unix.pm, avg 78µs/call
sub compare {
232600ns croak("Usage: compare( file1, file2 [, buffersize]) ")
24 unless(@_ == 2 || @_ == 3);
25
262700ns my ($from,$to,$size) = @_;
272800ns my $text_mode = defined($size) && (ref($size) eq 'CODE' || $size < 0);
28
292200ns my ($fromsize,$closefrom,$closeto);
3022µs local (*FROM, *TO);
31
322200ns croak("from undefined") unless (defined $from);
332200ns croak("to undefined") unless (defined $to);
34
3522µs if (ref($from) &&
36 (UNIVERSAL::isa($from,'GLOB') || UNIVERSAL::isa($from,'IO::Handle'))) {
37 *FROM = *$from;
38 } elsif (ref(\$from) eq 'GLOB') {
39 *FROM = $from;
40 } else {
41229µs221µs open(FROM,"<",$from) or goto fail_open1;
# spent 21µs making 2 calls to File::Compare::CORE:open, avg 10µs/call
422700ns unless ($text_mode) {
4328µs22µs binmode FROM;
# spent 2µs making 2 calls to File::Compare::CORE:binmode, avg 1µs/call
4426µs21µs $fromsize = -s FROM;
# spent 1µs making 2 calls to File::Compare::CORE:ftsize, avg 600ns/call
45 }
4621µs $closefrom = 1;
47 }
48
4922µs if (ref($to) &&
50 (UNIVERSAL::isa($to,'GLOB') || UNIVERSAL::isa($to,'IO::Handle'))) {
51 *TO = *$to;
52 } elsif (ref(\$to) eq 'GLOB') {
53 *TO = $to;
54 } else {
55217µs212µs open(TO,"<",$to) or goto fail_open2;
# spent 12µs making 2 calls to File::Compare::CORE:open, avg 6µs/call
5625µs21µs binmode TO unless $text_mode;
# spent 1µs making 2 calls to File::Compare::CORE:binmode, avg 500ns/call
5721µs $closeto = 1;
58 }
59
6021µs if (!$text_mode && $closefrom && $closeto) {
61 # If both are opened files we know they differ if their size differ
6225µs21µs goto fail_inner if $fromsize != -s TO;
# spent 1µs making 2 calls to File::Compare::CORE:ftsize, avg 650ns/call
63 }
64
652400ns if ($text_mode) {
66 local $/ = "\n";
67 my ($fline,$tline);
68 while (defined($fline = <FROM>)) {
69 goto fail_inner unless defined($tline = <TO>);
70 if (ref $size) {
71 # $size contains ref to comparison function
72 goto fail_inner if &$size($fline, $tline);
73 } else {
74 goto fail_inner if $fline ne $tline;
75 }
76 }
77 goto fail_inner if defined($tline = <TO>);
78 }
79 else {
802500ns unless (defined($size) && $size > 0) {
812400ns $size = $fromsize || -s TO || 0;
822400ns $size = 1024 if $size < 512;
832400ns $size = $Too_Big if $size > $Too_Big;
84 }
85
862200ns my ($fr,$tr,$fbuf,$tbuf);
872700ns $fbuf = $tbuf = '';
88221µs213µs while(defined($fr = read(FROM,$fbuf,$size)) && $fr > 0) {
# spent 13µs making 2 calls to File::Compare::CORE:read, avg 6µs/call
89213µs36µs unless (defined($tr = read(TO,$tbuf,$fr)) && $tbuf eq $fbuf) {
# spent 6µs making 3 calls to File::Compare::CORE:read, avg 2µs/call
9017µs goto fail_inner;
91 }
92 }
9315µs11µs goto fail_inner if defined($tr = read(TO,$tbuf,$size)) && $tr > 0;
# spent 1µs making 1 call to File::Compare::CORE:read
94 }
95
9616µs13µs close(TO) || goto fail_open2 if $closeto;
# spent 3µs making 1 call to File::Compare::CORE:close
9713µs11µs close(FROM) || goto fail_open1 if $closefrom;
# spent 1µs making 1 call to File::Compare::CORE:close
98
9913µs return 0;
100
101 # All of these contortions try to preserve error messages...
10219µs13µs fail_inner:
# spent 3µs making 1 call to File::Compare::CORE:close
103 close(TO) || goto fail_open2 if $closeto;
10414µs12µs close(FROM) || goto fail_open1 if $closefrom;
# spent 2µs making 1 call to File::Compare::CORE:close
105
10615µs return 1;
107
108 fail_open2:
109 if ($closefrom) {
110 my $status = $!;
111 $! = 0;
112 close FROM;
113 $! = $status unless $!;
114 }
115 fail_open1:
116 return -1;
117}
118
119sub cmp;
12012µs*cmp = \&compare;
121
122sub compare_text {
123 my ($from,$to,$cmp) = @_;
124 croak("Usage: compare_text( file1, file2 [, cmp-function])")
125 unless @_ == 2 || @_ == 3;
126 croak("Third arg to compare_text() function must be a code reference")
127 if @_ == 3 && ref($cmp) ne 'CODE';
128
129 # Using a negative buffer size puts compare into text_mode too
130 $cmp = -1 unless defined $cmp;
131 compare($from, $to, $cmp);
132}
133
13415µs1;
135
136__END__
 
# spent 3µs within File::Compare::CORE:binmode which was called 4 times, avg 775ns/call: # 2 times (2µs+0s) by File::Compare::compare at line 43, avg 1µs/call # 2 times (1µs+0s) by File::Compare::compare at line 56, avg 500ns/call
sub File::Compare::CORE:binmode; # opcode
# spent 8µs within File::Compare::CORE:close which was called 4 times, avg 2µs/call: # once (3µs+0s) by File::Compare::compare at line 102 # once (3µs+0s) by File::Compare::compare at line 96 # once (2µs+0s) by File::Compare::compare at line 104 # once (1µs+0s) by File::Compare::compare at line 97
sub File::Compare::CORE:close; # opcode
# spent 2µs within File::Compare::CORE:ftsize which was called 4 times, avg 625ns/call: # 2 times (1µs+0s) by File::Compare::compare at line 62, avg 650ns/call # 2 times (1µs+0s) by File::Compare::compare at line 44, avg 600ns/call
sub File::Compare::CORE:ftsize; # opcode
# spent 33µs within File::Compare::CORE:open which was called 4 times, avg 8µs/call: # 2 times (21µs+0s) by File::Compare::compare at line 41, avg 10µs/call # 2 times (12µs+0s) by File::Compare::compare at line 55, avg 6µs/call
sub File::Compare::CORE:open; # opcode
# spent 20µs within File::Compare::CORE:read which was called 6 times, avg 3µs/call: # 3 times (6µs+0s) by File::Compare::compare at line 89, avg 2µs/call # 2 times (13µs+0s) by File::Compare::compare at line 88, avg 6µs/call # once (1µs+0s) by File::Compare::compare at line 93
sub File::Compare::CORE:read; # opcode