| 1 | # Simple test to check the speed of Crypt::CAST5_PP |
| 2 | |
| 3 | # To run, cd to the Crypt-CAST5-x.xx directory and type |
| 4 | # make |
| 5 | # perl test/speedtest.pl |
| 6 | |
| 7 | use strict; |
| 8 | use warnings; |
| 9 | |
| 10 | use lib "blib/lib"; |
| 11 | use lib "blib/arch"; |
| 12 | use Crypt::CAST5; |
| 13 | use Time::HiRes qw( gettimeofday tv_interval ); |
| 14 | |
| 15 | my ($cast5, $start, $end, $text, $i); |
| 16 | $cast5 = Crypt::CAST5->new(); |
| 17 | |
| 18 | $cast5->init(pack "H*", "12345678901234567890"); |
| 19 | $start = [ gettimeofday() ]; |
| 20 | for ($i = 0; $i < 100_000; $i++) { |
| 21 | $text = pack "n4", $i, $i, $i, $i; |
| 22 | $cast5->encrypt($text); |
| 23 | } |
| 24 | $end = [ gettimeofday() ]; |
| 25 | print "Time for 100k 80-bit encryptions: ", tv_interval($start, $end), " sec\n"; |
| 26 | |
| 27 | $cast5->init(pack "H*", "0123456789abcdef0123456789abcdef"); |
| 28 | $start = [ gettimeofday() ]; |
| 29 | for ($i = 0; $i < 100_000; $i++) { |
| 30 | $text = pack "n4", $i, $i, $i, $i; |
| 31 | $cast5->encrypt($text); |
| 32 | } |
| 33 | $end = [ gettimeofday() ]; |
| 34 | print "Time for 100k 128-bit encryptions: ", tv_interval($start, $end), " sec\n"; |
| 35 | |
| 36 | # end speedtest.pl |