~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to extra/yassl/taocrypt/benchmark/benchmark.cpp

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
const int megs = 5;  // how much to test
67
67
 
68
 
const byte global_key[] = 
 
68
const byte key[] = 
69
69
{
70
70
    0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
71
71
    0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
81
81
};
82
82
 
83
83
 
84
 
byte global_plain [1024*1024];
85
 
byte global_cipher[1024*1024];
 
84
byte plain [1024*1024];
 
85
byte cipher[1024*1024];
86
86
 
87
87
 
88
88
void bench_des()
89
89
{
90
90
    DES_EDE3_CBC_Encryption enc;
91
 
    enc.SetKey(global_key, 16, iv);
 
91
    enc.SetKey(key, 16, iv);
92
92
 
93
93
    double start = current_time();
94
94
 
95
95
    for(int i = 0; i < megs; i++)
96
 
        enc.Process(global_plain, global_cipher, sizeof(global_plain));
 
96
        enc.Process(plain, cipher, sizeof(plain));
97
97
 
98
98
    double total = current_time() - start;
99
99
 
107
107
void bench_aes(bool show)
108
108
{
109
109
    AES_CBC_Encryption enc;
110
 
    enc.SetKey(global_key, 16, iv);
 
110
    enc.SetKey(key, 16, iv);
111
111
 
112
112
    double start = current_time();
113
113
 
114
114
    for(int i = 0; i < megs; i++)
115
 
        enc.Process(global_plain, global_cipher, sizeof(global_plain));
 
115
        enc.Process(plain, cipher, sizeof(plain));
116
116
 
117
117
    double total = current_time() - start;
118
118
 
127
127
void bench_twofish()
128
128
{
129
129
    Twofish_CBC_Encryption enc;
130
 
    enc.SetKey(global_key, 16, iv);
 
130
    enc.SetKey(key, 16, iv);
131
131
 
132
132
    double start = current_time();
133
133
 
134
134
    for(int i = 0; i < megs; i++)
135
 
        enc.Process(global_plain, global_cipher, sizeof(global_plain));
 
135
        enc.Process(plain, cipher, sizeof(plain));
136
136
 
137
137
    double total = current_time() - start;
138
138
 
147
147
void bench_blowfish()
148
148
{
149
149
    Blowfish_CBC_Encryption enc;
150
 
    enc.SetKey(global_key, 16, iv);
 
150
    enc.SetKey(key, 16, iv);
151
151
 
152
152
    double start = current_time();
153
153
 
154
154
    for(int i = 0; i < megs; i++)
155
 
        enc.Process(global_plain, global_cipher, sizeof(global_plain));
 
155
        enc.Process(plain, cipher, sizeof(plain));
156
156
 
157
157
    double total = current_time() - start;
158
158
 
166
166
void bench_arc4()
167
167
{
168
168
    ARC4 enc;
169
 
    enc.SetKey(global_key, 16);
 
169
    enc.SetKey(key, 16);
170
170
 
171
171
    double start = current_time();
172
172
 
173
173
    for(int i = 0; i < megs; i++)
174
 
        enc.Process(global_cipher, global_plain, sizeof(global_plain));
 
174
        enc.Process(cipher, plain, sizeof(plain));
175
175
 
176
176
    double total = current_time() - start;
177
177
 
191
191
 
192
192
    
193
193
    for(int i = 0; i < megs; i++)
194
 
        hash.Update(global_plain, sizeof(global_plain));
 
194
        hash.Update(plain, sizeof(plain));
195
195
   
196
196
    hash.Final(digest);
197
197
 
213
213
 
214
214
    
215
215
    for(int i = 0; i < megs; i++)
216
 
        hash.Update(global_plain, sizeof(global_plain));
 
216
        hash.Update(plain, sizeof(plain));
217
217
   
218
218
    hash.Final(digest);
219
219
 
241
241
 
242
242
    
243
243
    for(int i = 0; i < megs; i++)
244
 
        hash.Update(global_plain, sizeof(global_plain));
 
244
        hash.Update(plain, sizeof(plain));
245
245
   
246
246
    hash.Final(digest);
247
247