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
/
Copy pathkdb.c
67 lines (52 loc) · 1.49 KB
/
kdb.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
/**
* @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 NUM_RUNS 7
#define CSV_STR_FMT "%s;%s;%d\n"
static void benchmarkDel (void)
{
ksDel (large);
}
int main (void)
{
benchmarkCreate ();
benchmarkFillup ();
fprintf (stdout, "%s;%s;%s\n", "plugin", "operation", "microseconds");
{
KeySet * returned = ksNew (0, KS_END);
Key * parentKey = keyNew ("user:/", KEY_END);
timeInit ();
KDB * handle = kdbOpen (NULL, parentKey);
fprintf (stdout, CSV_STR_FMT, "core", "kdbOpen", timeGetDiffMicroseconds ());
kdbGet (handle, returned, parentKey);
fprintf (stdout, CSV_STR_FMT, "core", "kdbGet", timeGetDiffMicroseconds ());
// ksAppend (returned, large);
kdbSet (handle, large, parentKey);
fprintf (stdout, CSV_STR_FMT, "core", "kdbSet", timeGetDiffMicroseconds ());
kdbClose (handle, parentKey);
keyDel (parentKey);
ksDel (returned);
}
for (size_t i = 0; i < NUM_RUNS; ++i)
{
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 ());
kdbClose (handle, parentKey);
ksDel (returned);
keyDel (parentKey);
}
benchmarkDel ();
}