3 require_once('Crypto.php');
5 // Note: By default, the runtime tests are "cached" and not re-executed for
6 // every call. To disable this, look at the RuntimeTest() function.
8 $start = microtime(true);
9 for ($i = 0; $i < 1000; $i++) {
10 $key = Crypto::CreateNewRandomKey();
12 $end = microtime(true);
13 showResults("CreateNewRandomKey()", $start, $end, 1000);
15 $start = microtime(true);
16 for ($i = 0; $i < 100; $i++) {
17 $ciphertext = Crypto::Encrypt(
18 str_repeat("A", 1024*1024),
22 $end = microtime(true);
23 showResults("Encrypt(1MB)", $start, $end, 100);
25 $start = microtime(true);
26 for ($i = 0; $i < 1000; $i++) {
27 $ciphertext = Crypto::Encrypt(
28 str_repeat("A", 1024),
32 $end = microtime(true);
33 showResults("Encrypt(1KB)", $start, $end, 1000);
35 function showResults($type, $start, $end, $count)
37 $time = $end - $start;
38 $rate = $count / $time;
39 echo "$type: $rate calls/s\n";