I just profiled my code with DProf:
Total Elapsed Time = 9.969922 Seconds
User+System Time = 0.049922 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
40.0 0.020 0.020 2 0.0100 0.0100 main::difference
40.0 0.020 0.020 3 0.0067 0.0066 main::BEGIN
0.00 - -0.000 1 - - DynaLoader::dl_install_xsub
0.00 - -0.000 1 - - Data::Dumper::bootstrap
0.00 - -0.000 1 - - strict::import
0.00 - -0.000 1 - - warnings::BEGIN
0.00 - -0.000 1 - - warnings::import
0.00 - -0.000 1 - - bytes::import
0.00 - -0.000 1 - - strict::bits
0.00 - -0.000 1 - - DynaLoader::dl_load_file
0.00 - -0.000 1 - - DynaLoader::dl_undef_symbols
0.00 - -0.000 1 - - DynaLoader::dl_find_symbol
0.00 - -0.000 1 - - overload::BEGIN
0.00 - -0.000 2 - - warnings::register::mkMask
0.00 - -0.000 2 - - Exporter::import
So my difference
subroutine takes around 40% of the time, and BEGIN
takes up the other 40%. I'm not so sure what is going on for the other 9.8 seconds. Could anyone explain to me what Perl is doing for the rest of the time?
Basically, my code takes in two arrays, performs a set difference, and writes to a file. The files are not too large (23,028 characters). This is my difference
subroutine, if you are curious:
sub difference {
my @array1 = @{$_[0]};
my @array2 = @{$_[1]};
my %in_array1 = map {$_ => 1} @array1;
my @diff = grep {not $in_array1{$_}} @array2;
return @diff;
}