Hi All,
working on a server/client that encrypts payloads (in chunks) for transmission,
trying to profile payloads prior to sending but puzzled by no performance hit
by adding compression.
Question: Anyone have any insight why there virtually no loss of processing
performance when adding zlib compression to the process (perl is just that good
both bin and ascii)?
I expected a significant performance hit when adding compression to the
processing, but did Not see evidence of a loss from DProf (am I reading DProf
results correctly?).
I tested results using "perl -d:DProf test.pl" in each case on v5.8.9 built for
MSWin32-x86-multi-thread, am I just interpreting DProf results incorrectly?
I am considering enforcing policy of always encrypting and compressing all IO
since there is not too much loss between the two.
below are the test results from DProf:
----Total_test_results_according_to_DProf----
Test1(BIN_File): 7.5MB MP3 File - No Compression:CBC Blowfish, 18Byte Key
Total Elapsed Time = 31.74240 Seconds
User+System Time = 30.38840 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
105. 31.93 39.798 2 15.969 19.898 Crypt::CBC::crypt
9.88 3.001 3.867 924932 0.0000 0.0000 Crypt::Blowfish::encrypt
9.31 2.828 3.976 924932 0.0000 0.0000 Crypt::Blowfish::decrypt
6.63 2.014 2.014 184986 0.0000 0.0000 Crypt::Blowfish::crypt
0.11 0.032 18.798 1 0.0320 18.797 main::decrypt_this
0.05 0.016 21.109 1 0.0160 21.108 main::encrypt_this
0.05 0.016 0.016 1 0.0160 0.0160 Crypt::CBC::_generate_iv_and_ciphe
r_from_datastream
0.05 0.016 0.016 3 0.0053 0.0053 vars::BEGIN
0.05 0.016 0.016 1 0.0160 0.0160 DynaLoader::bootstrap
0.05 0.015 21.062 1 0.0150 21.061 Crypt::CBC::encrypt
0.05 0.015 18.766 1 0.0150 18.765 Crypt::CBC::decrypt
0.05 0.015 0.015 5 0.0030 0.0030 File::Basename::BEGIN
0.00 0.000 0.000 1 0.0000 0.0000 Config::launcher
0.00 0.000 0.000 1 0.0000 0.0000 Config::fetch_string
0.00 - -0.000 1 - - Config::import
Test2(BIN_FILE): 7.5MB MP3 File - With zlib Compression:CBC Blowfish, 18Byte Key
Total Elapsed Time = 32.09128 Seconds
User+System Time = 30.81728 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
98.5 30.36 38.577 2 15.180 19.288 Crypt::CBC::crypt
10.2 3.166 4.482 901498 0.0000 0.0000 Crypt::Blowfish::decrypt
8.95 2.759 3.734 901498 0.0000 0.0000 Crypt::Blowfish::encrypt
7.43 2.290 2.290 180299 0.0000 0.0000 Crypt::Blowfish::crypt
1.97 0.608 0.608 1 0.6080 0.6080 Compress::Raw::Zlib::deflateStream
::deflate
0.36 0.110 0.110 1 0.1100 0.1100 Compress::Raw::Zlib::inflateStream
::inflate
0.10 0.032 18.798 1 0.0320 18.797 Crypt::CBC::decrypt
0.10 0.031 0.093 18 0.0017 0.0052 Compress::Zlib::BEGIN
0.05 0.016 19.827 1 0.0160 19.826 Crypt::CBC::encrypt
0.05 0.016 20.483 1 0.0160 20.482 main::encrypt_this
0.05 0.016 0.016 1 0.0160 0.0159 ActivePerl::Config::override
0.05 0.016 0.624 1 0.0160 0.6239 Compress::Zlib::compress
0.05 0.016 0.016 7 0.0023 0.0023 IO::Handle::BEGIN
0.05 0.016 0.016 6 0.0027 0.0027 Crypt::CBC::BEGIN
0.05 0.016 0.016 9 0.0018 0.0018 IO::Compress::RawDeflate::BEGIN
Test1(ASCII_FILE): 618K Text ASCII File - No Compression:CBC Blowfish, 18Byte
Key
Total Elapsed Time = 0.370435 Seconds
User+System Time = 0.377435 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
174. 0.659 1.066 2 0.3295 0.5330 Crypt::CBC::crypt
41.8 0.158 0.158 158040 0.0000 0.0000 Crypt::Blowfish::crypt
39.4 0.149 0.226 79020 0.0000 0.0000 Crypt::Blowfish::encrypt
26.4 0.100 0.182 79020 0.0000 0.0000 Crypt::Blowfish::decrypt
4.24 0.016 0.016 6 0.0027 0.0027 ActiveState::Path::BEGIN
4.24 0.016 0.032 2 0.0080 0.0158 Crypt::CBC::new
3.97 0.015 0.015 6 0.0025 0.0025 Crypt::CBC::BEGIN
0.00 0.000 0.000 1 0.0000 0.0000 Config::launcher
0.00 0.000 0.000 1 0.0000 0.0000 Config::fetch_string
0.00 - -0.000 1 - - AutoLoader::AUTOLOAD
0.00 - -0.000 1 - - AutoLoader::find_filename
0.00 - -0.000 2 - - AutoLoader::__ANON__
0.00 - -0.000 1 - - Cwd::bootstrap
0.00 - -0.000 1 - - re::bits
0.00 - -0.000 1 - - warnings::import
Test2(ASCII_FILE): 618K Text ASCII File - With zlib Compression:CBC Blowfish,
18Byte Key
Total Elapsed Time = 0.169119 Seconds
User+System Time = 0.164119 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
19.5 0.032 0.093 18 0.0018 0.0052 Compress::Zlib::BEGIN
18.8 0.031 0.031 1 0.0310 0.0310 Compress::Raw::Zlib::deflateStream
::deflate
9.75 0.016 0.016 1 0.0160 0.0160 warnings::BEGIN
9.75 0.016 0.016 6 0.0027 0.0027 ActiveState::Path::BEGIN
9.75 0.016 0.016 7 0.0023 0.0023 IO::File::BEGIN
9.75 0.016 0.016 7 0.0023 0.0023 IO::Uncompress::RawInflate::BEGIN
9.14 0.015 0.015 5 0.0030 0.0030 File::GlobMapper::BEGIN
9.14 0.015 0.015 81 0.0002 0.0002 constant::import
8.53 0.014 0.010 2 0.0068 0.0048 Crypt::CBC::crypt
0.00 0.000 0.000 1 0.0000 0.0000 File::Glob::GLOB_NOCASE
0.00 0.000 0.000 1 0.0000 0.0000 Config::launcher
0.00 0.000 0.000 1 0.0000 0.0000 Config::fetch_string
0.00 - -0.000 1 - - Compress::Raw::Zlib::deflateStream
0.0000 ::flush
0.00 - -0.000 1 - - Compress::Raw::Zlib::deflateStream
0.0000 ::DESTROY
0.00 - -0.000 1 - - Config::_fetch_string
----EOF_Total_test_results_according_to_DProf----
--test.pl_snip_pertinent_perl_src_win32_Vista_2GB_Physical_Mem_2X_CPU_Binary
build 825 [288577]----
use strict;
use Crypt::CBC;
use Compress::Zlib;
my $key = 'Zok*&^#iaYdfnSs2!@';
local $/ = undef;
open( INPUTFH, "testimage.png" ) or die "Test croaked while opening file:
testimage.png\n";
binmode INPUTFH;
my $unciphered_input = <INPUTFH>;
close INPUTFH;
my $cyphered_input = encrypt_this($key, $unciphered_input);
open OUTFILE, "> testimage_outfile.png";
binmode OUTFILE;
print OUTFILE $cyphered_input;
close OUTFILE;
my $plain_data_again = decrypt_this($key, $cyphered_input);
open OUTFILE, "> testimage_decrypted_outfile.png";
binmode OUTFILE;
print OUTFILE $plain_data_again;
close OUTFILE;
sub encrypt_this {
my ($key, $plain_bytes) = @_;
my $zipped_payload = compress($plain_bytes);
my $cipher = Crypt::CBC->new( -key => $key, -cipher => 'Blowfish');
my $cipherdat = $cipher->encrypt($zipped_payload);
return $cipherdat;
}
sub decrypt_this {
my ($key, $ciphered_bytes) = @_;
my $cipher = Crypt::CBC->new( -key => $key, -cipher => 'Blowfish');
my $deciphered_output = $cipher->decrypt($ciphered_bytes);
my $uzipped_output = uncompress($deciphered_output);
return $uzipped_output;
}
--EO_test.pl_snip_pertinent_perl_src_win32_Vista_2GB_Physical_Mem_2X_CPU_Binary
build 825 [288577]----
Thanks for any insight...
-BigAl
[email protected]
[email protected]
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs