Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Benchmark for KDB
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #include <stdio.h>
10 :
11 : #include <benchmarks.h>
12 : #include <kdb.h>
13 :
14 : #define NUM_RUNS 7
15 :
16 : #define CSV_STR_FMT "%s;%s;%d\n"
17 :
18 :
19 : static void benchmarkDel (void)
20 : {
21 0 : ksDel (large);
22 : }
23 :
24 0 : int main (void)
25 : {
26 0 : benchmarkCreate ();
27 0 : benchmarkFillup ();
28 :
29 0 : fprintf (stdout, "%s;%s;%s\n", "plugin", "operation", "microseconds");
30 : {
31 0 : KeySet * returned = ksNew (0, KS_END);
32 0 : Key * parentKey = keyNew ("user", KEY_END);
33 :
34 0 : timeInit ();
35 0 : KDB * handle = kdbOpen (parentKey);
36 0 : fprintf (stdout, CSV_STR_FMT, "core", "kdbOpen", timeGetDiffMicroseconds ());
37 :
38 0 : kdbGet (handle, returned, parentKey);
39 0 : fprintf (stdout, CSV_STR_FMT, "core", "kdbGet", timeGetDiffMicroseconds ());
40 :
41 : // ksAppend (returned, large);
42 0 : kdbSet (handle, large, parentKey);
43 0 : fprintf (stdout, CSV_STR_FMT, "core", "kdbSet", timeGetDiffMicroseconds ());
44 0 : kdbClose (handle, parentKey);
45 0 : keyDel (parentKey);
46 0 : ksDel (returned);
47 : }
48 :
49 0 : for (size_t i = 0; i < NUM_RUNS; ++i)
50 : {
51 0 : timeInit ();
52 0 : Key * parentKey = keyNew ("user/benchmark", KEY_END);
53 0 : KDB * handle = kdbOpen (parentKey);
54 0 : fprintf (stdout, CSV_STR_FMT, "core", "kdbOpen", timeGetDiffMicroseconds ());
55 :
56 0 : KeySet * returned = ksNew (0, KS_END);
57 0 : timeInit ();
58 0 : kdbGet (handle, returned, parentKey);
59 0 : fprintf (stdout, CSV_STR_FMT, "core", "kdbGet", timeGetDiffMicroseconds ());
60 :
61 0 : kdbClose (handle, parentKey);
62 0 : ksDel (returned);
63 0 : keyDel (parentKey);
64 : }
65 :
66 : benchmarkDel ();
67 : }
|