aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/bench.cpp
blob: 7d53e055708674006e98cba8c9dea3ed7b20179f (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <botan/benchmark.h>
#include <botan/init.h>
#include <botan/auto_rng.h>
#include <botan/libstate.h>

using namespace Botan;

#include <iostream>

const std::string algos[] = {
   "AES-128",
   "AES-192",
   "AES-256",
   "Blowfish",
   "CAST-128",
   "CAST-256",
   "DES",
   "DESX",
   "TripleDES",
   "GOST",
   "IDEA",
   "KASUMI",
   "Lion(SHA-256,Turing,8192)",
   "Luby-Rackoff(SHA-512)",
   "MARS",
   "MISTY1",
   "Noekeon",
   "RC2",
   "RC5(12)",
   "RC5(16)",
   "RC6",
   "SAFER-SK(10)",
   "SEED",
   "Serpent",
   "Skipjack",
   "Square",
   "TEA",
   "Twofish",
   "XTEA",
   "Adler32",
   "CRC32",
   "FORK-256",
   "GOST-34.11",
   "HAS-160",
   "MD2",
   "MD4",
   "MD5",
   "RIPEMD-128",
   "RIPEMD-160",
   "SHA-160",
   "SHA-256",
   "SHA-384",
   "SHA-512",
   "Skein-512",
   "Tiger",
   "Whirlpool",
   "CMAC(AES-128)",
   "HMAC(SHA-1)",
   "X9.19-MAC",
   "",
};

int main()
   {
   LibraryInitializer init;

   u32bit milliseconds = 1000;
   AutoSeeded_RNG rng;

   Algorithm_Factory& af = global_state().algorithm_factory();

   for(u32bit i = 0; algos[i] != ""; ++i)
      {
      std::string algo = algos[i];

      std::map<std::string, double> speeds =
         algorithm_benchmark(algos[i], milliseconds, rng, af);

      std::cout << algo << ":";

      for(std::map<std::string, double>::const_iterator i = speeds.begin();
          i != speeds.end(); ++i)
         {
         std::cout << " " << i->second << " [" << i->first << "]";
         }
      std::cout << "\n";
      }
   }