forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkdbget.c
48 lines (37 loc) · 997 Bytes
/
kdbget.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
/**
* @file
*
* @brief Benchmark for KDB
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*/
#include <stdio.h>
#include <benchmarks.h>
#include <kdb.h>
#define CSV_STR_FMT "%s;%s;%d\n"
static void benchmarkDel (void)
{
ksDel (large);
}
int main (void)
{
fprintf (stdout, "%s;%s;%s\n", "plugin", "operation", "microseconds");
timeInit ();
Key * parentKey = keyNew ("user:/benchmark", KEY_END);
KDB * handle = kdbOpen (NULL, parentKey);
fprintf (stdout, CSV_STR_FMT, "core", "kdbOpen", timeGetDiffMicroseconds ());
KeySet * returned = ksNew (0, KS_END);
timeInit ();
kdbGet (handle, returned, parentKey);
fprintf (stdout, CSV_STR_FMT, "core", "kdbGet", timeGetDiffMicroseconds ());
if (ksGetSize (returned) == 0)
{
fprintf (stderr, "error: no keys returned. make sure you actually have something in %s!", keyName (parentKey));
goto error;
}
error:
kdbClose (handle, parentKey);
ksDel (returned);
keyDel (parentKey);
benchmarkDel ();
}