This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
large.c
117 lines (91 loc) · 1.82 KB
/
large.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* @file
*
* @brief
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <benchmarks.h>
KDB * kdb;
Key * key;
void benchmarkOpen (void)
{
kdb = kdbOpen (NULL, key);
}
void benchmarkInread (void)
{
KeySet * n = ksNew (0, KS_END);
kdbGet (kdb, n, key);
ksDel (n);
}
void benchmarkReadin (void)
{
KeySet * n = ksNew (0, KS_END);
kdbGet (kdb, n, key);
ksDel (n);
}
void benchmarkLookupByName (void)
{
int i, j;
char name[KEY_NAME_LENGTH + 1];
for (i = 0; i < NUM_DIR; i++)
{
snprintf (name, KEY_NAME_LENGTH, "%s/%s%d", KEY_ROOT, "dir", i);
ksLookupByName (large, name, 0);
for (j = 0; j < NUM_KEY; j++)
{
snprintf (name, KEY_NAME_LENGTH, "%s/%s%d/%s%d", KEY_ROOT, "dir", i, "key", j);
ksLookupByName (large, name, 0);
}
}
}
void benchmarkReread (void)
{
kdbGet (kdb, large, key);
}
void benchmarkInwrite (void)
{
kdbSet (kdb, large, key);
}
void benchmarkRewrite (void)
{
kdbSet (kdb, large, key);
}
void benchmarkWriteout (void)
{
kdbSet (kdb, large, key);
}
void benchmarkClose (void)
{
kdbClose (kdb, key);
}
int main (void)
{
key = keyNew (KEY_ROOT, KEY_END);
timeInit ();
benchmarkCreate ();
timePrint ("Created empty keyset");
benchmarkFillup ();
timePrint ("New large keyset");
benchmarkOpen ();
keySetName (key, KEY_ROOT);
timePrint ("Opened key database");
benchmarkInread ();
timePrint ("Initialize read");
benchmarkInwrite ();
timePrint ("Initialize write");
benchmarkWriteout ();
timePrint ("Write key database");
benchmarkRewrite ();
timePrint ("Rewrite key database");
benchmarkReadin ();
timePrint ("Read in key database");
benchmarkLookupByName ();
timePrint ("Lookup key database");
benchmarkReread ();
timePrint ("Re read key database");
benchmarkClose ();
timePrint ("Closed key database");
ksDel (large);
keyDel (key);
}