-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbench-wcoj.cpp
More file actions
78 lines (62 loc) · 1.93 KB
/
bench-wcoj.cpp
File metadata and controls
78 lines (62 loc) · 1.93 KB
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
#include <stdio.h>
#include <iostream>
#include "common.h"
#include "operators.h"
#include "sqlite3.h"
// populated later
#define MAX_SCALE 1000000
int dsR1_pos[2];
int dsR1_crd[MAX_SCALE + 10];
int dsR2_pos[MAX_SCALE + 10];
int dsR2_crd[2 * MAX_SCALE + 10];
int dsS1_pos[2];
int dsS1_crd[MAX_SCALE + 10];
int dsS2_pos[MAX_SCALE + 10];
int dsS2_crd[2 * MAX_SCALE + 10];
int dsT1_pos[2];
int dsT1_crd[MAX_SCALE + 10];
int dsT2_pos[MAX_SCALE + 10];
int dsT2_crd[2 * MAX_SCALE + 10];
#include "gen_wcoj.c"
static int populate_wcoj(sqlite3* db) {
char* zErrMsg;
int rc;
void* data = NULL;
#define GET_TBL2(tbl_name, col1, col2) \
do { \
rc = sqlite3_exec( \
db, "SELECT " #col1 ", " #col2 " FROM " #tbl_name " ORDER BY 1, 2", \
gen_callback_wcoj_##tbl_name, (void*)data, &zErrMsg); \
if (rc != SQLITE_OK) { \
printf("%s:%d: %s\n", __FILE__, __LINE__, zErrMsg); \
return rc; \
} \
} while (false)
GET_TBL2(R, a, b);
GET_TBL2(S, b, c);
GET_TBL2(T, a, c);
return rc;
}
static sqlite3* db;
int res;
int main(int argc, char* argv[]) {
int rc = SQLITE_OK;
sqlite3_initialize();
rc = sqlite3_open(argc >= 1 ? argv[1] : "data/pldi.db", &db);
if (rc) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
return (0);
} else {
fprintf(stderr, "Opened database successfully\n");
}
time([]() { return populate_wcoj(db); }, "populate_wcoj", 1);
printf("Loaded\n");
time([&]() {
for (int i = 0; i < 1000; ++i) {
res = wcoj();
}
return res;
}, "wcojx1000", 5);
sqlite3_close(db);
return 0;
}