File: speedtest.pl

package info (click to toggle)
libcrypt-cast5-perl 0.05-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: ansic: 622; perl: 70; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Simple test to check the speed of Crypt::CAST5_PP

# To run, cd to the Crypt-CAST5-x.xx directory and type
#     make
#     perl test/speedtest.pl

use strict;
use warnings;

use lib "blib/lib";
use lib "blib/arch";
use Crypt::CAST5;
use Time::HiRes qw( gettimeofday tv_interval );

my ($cast5, $start, $end, $text, $i);
$cast5 = Crypt::CAST5->new();

$cast5->init(pack "H*", "12345678901234567890");
$start = [ gettimeofday() ];
for ($i = 0; $i < 100_000; $i++) {
  $text = pack "n4", $i, $i, $i, $i;
  $cast5->encrypt($text);
}
$end = [ gettimeofday() ];
print "Time for 100k 80-bit encryptions: ", tv_interval($start, $end), " sec\n";

$cast5->init(pack "H*", "0123456789abcdef0123456789abcdef");
$start = [ gettimeofday() ];
for ($i = 0; $i < 100_000; $i++) {
  $text = pack "n4", $i, $i, $i, $i;
  $cast5->encrypt($text);
}
$end = [ gettimeofday() ];
print "Time for 100k 128-bit encryptions: ", tv_interval($start, $end), " sec\n";

# end speedtest.pl