-
Notifications
You must be signed in to change notification settings - Fork 46
/
benchmulti.c
66 lines (51 loc) · 1.37 KB
/
benchmulti.c
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
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <openssl/evp.h>
#include "fastpbkdf2.h"
#define PASSWORD (const void *) "password", 8
#define SALT (const void *) "saltsalt", 8
#include "benchutil.h"
static void sha1(uint32_t repeat, uint32_t iterations, size_t n)
{
uint8_t out[64];
assert(sizeof(out) >= n);
proctime cpu_end, cpu_start;
double wall_end, wall_start;
cpu_start = cpu_now();
wall_start = wall_now();
for (uint32_t i = 0; i < repeat; i++)
PKCS5_PBKDF2_HMAC_SHA1(PASSWORD, SALT,
iterations,
(int) n, out);
wall_end = wall_now();
cpu_end = cpu_now();
printf("openssl,sha1,%u,%u,%zu,%g,%g\n",
iterations,
repeat,
n,
proctime2secs(cpu_start, cpu_end),
wall_end - wall_start);
cpu_start = cpu_now();
wall_start = wall_now();
for (uint32_t i = 0; i < repeat; i++)
fastpbkdf2_hmac_sha1(PASSWORD, SALT,
iterations,
out, n);
wall_end = wall_now();
cpu_end = cpu_now();
printf("fastpbkdf2,sha1,%u,%u,%zu,%g,%g\n",
iterations,
repeat,
n,
proctime2secs(cpu_start, cpu_end),
wall_end - wall_start);
}
int main(void)
{
sha1(1, 1 << 22, 16);
sha1(1, 1 << 22, 32);
sha1(1, 1 << 22, 48);
sha1(1, 1 << 22, 64);
return 0;
}