#!/usr/bin/perl use strict; use warnings; use MIME::Base64; use Storable qw/nfreeze thaw/; my $count = 1_000_000; my $base64 = <<'TXT'; SOMEBASE64DATASOMEBASE64DATASOMEBASE64DATASOMEBASE64DATASOMEBASE64DATAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA TXT my $binary = decode_base64($base64); my $struct = thaw($binary); my ($t, $s) = (0,0); ########################################################### $t = time(); foreach (1..$count) { my $y = nfreeze($struct); } $t = time() - $t; $s = int($count/$t); print "nfreeze: time: $t sec; speed: $s req/sec\n"; $t = time(); foreach (1..$count) { my $y = thaw($binary); } $t = time() - $t; $s = int($count/$t); print "thaw: time: $t sec; speed: $s req/sec\n"; ########################################################### $t = time(); foreach (1..$count) { my $y = encode_base64($binary); } $t = time() - $t; $s = int($count/$t); print "encode_base64: time: $t sec; speed: $s req/sec\n"; $t = time(); foreach (1..$count) { my $y = decode_base64($base64); } $t = time() - $t; $s = int($count/$t); print "decode_base64: time: $t sec; speed: $s req/sec\n"; ########################################################### $t = time(); foreach (1..$count) { my $y = encode_base64(nfreeze($struct)); } $t = time() - $t; $s = int($count/$t); print "STORE: time: $t sec; speed: $s req/sec\n"; $t = time(); foreach (1..$count) { my $y = thaw(decode_base64($base64)); } $t = time() - $t; $s = int($count/$t); print "GET: time: $t sec; speed: $s req/sec\n"; print "DONE\n";