| 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 strictscip-perl cpan Crypt-CAST5 0.05 strict/; |
| 8 | use warningsscip-perl cpan Crypt-CAST5 0.05 warnings/; |
| 9 | |
| 10 | use libscip-perl cpan Crypt-CAST5 0.05 lib/ "blib/lib"; |
| 11 | use libscip-perl cpan Crypt-CAST5 0.05 lib/ "blib/arch"; |
| 12 | use Crypt::CAST5scip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/; |
| 13 | use Time::HiResscip-perl cpan Crypt-CAST5 0.05 Time/HiRes/ qw( gettimeofday tv_interval ); |
| 14 | |
| 15 | my ($cast5, $start, $end, $text, $i); |
| 16 | $cast5 = Crypt::CAST5->newscip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/new().(); |
| 17 | |
| 18 | $cast5->initscip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/init().(packscip-perl cpan Crypt-CAST5 0.05 main/pack(). "H*", "12345678901234567890"); |
| 19 | $start = [ gettimeofdayscip-perl cpan Crypt-CAST5 0.05 main/gettimeofday().() ]; |
| 20 | for ($i = 0; $i < 100_000; $i++) { |
| 21 | $text = packscip-perl cpan Crypt-CAST5 0.05 main/pack(). "n4", $i, $i, $i, $i; |
| 22 | $cast5->encryptscip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/encrypt().($text); |
| 23 | } |
| 24 | $end = [ gettimeofdayscip-perl cpan Crypt-CAST5 0.05 main/gettimeofday().() ]; |
| 25 | printscip-perl cpan Crypt-CAST5 0.05 main/print(). "Time for 100k 80-bit encryptions: ", tv_intervalscip-perl cpan Crypt-CAST5 0.05 main/tv_interval().($start, $end), " sec\n"; |
| 26 | |
| 27 | $cast5->initscip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/init().(packscip-perl cpan Crypt-CAST5 0.05 main/pack(). "H*", "0123456789abcdef0123456789abcdef"); |
| 28 | $start = [ gettimeofdayscip-perl cpan Crypt-CAST5 0.05 main/gettimeofday().() ]; |
| 29 | for ($i = 0; $i < 100_000; $i++) { |
| 30 | $text = packscip-perl cpan Crypt-CAST5 0.05 main/pack(). "n4", $i, $i, $i, $i; |
| 31 | $cast5->encryptscip-perl cpan Crypt-CAST5 0.05 Crypt/CAST5/encrypt().($text); |
| 32 | } |
| 33 | $end = [ gettimeofdayscip-perl cpan Crypt-CAST5 0.05 main/gettimeofday().() ]; |
| 34 | printscip-perl cpan Crypt-CAST5 0.05 main/print(). "Time for 100k 128-bit encryptions: ", tv_intervalscip-perl cpan Crypt-CAST5 0.05 main/tv_interval().($start, $end), " sec\n"; |
| 35 | |
| 36 | # end speedtest.pl |