|
@@ -2,49 +2,72 @@
|
|
|
#include "graph.h"
|
|
|
|
|
|
#ifndef NT
|
|
|
-#define NT 1000000
|
|
|
+#define NT 100000
|
|
|
#endif
|
|
|
|
|
|
-static int test_graph_add_batch()
|
|
|
+static LSUP_Triple *
|
|
|
+generate_triples()
|
|
|
{
|
|
|
- size_t nt = NT;
|
|
|
-
|
|
|
LSUP_Triple *trp;
|
|
|
- CRITICAL(trp = malloc(nt * sizeof(LSUP_Triple)));
|
|
|
- for (size_t i = 0; i < nt; i++) {
|
|
|
- //printf("i: %lu\n", i);
|
|
|
- LSUP_uri_new (NULL, trp[i].s);
|
|
|
- LSUP_uri_new (NULL, trp[i].p);
|
|
|
- LSUP_uri_new (NULL, trp[i].o);
|
|
|
+ CRITICAL(trp = malloc(NT * sizeof(LSUP_Triple)));
|
|
|
+ char sstr[32], pstr[32], ostr[32];
|
|
|
+
|
|
|
+ for (size_t i = 0; i < NT; i++) {
|
|
|
+ sprintf(sstr, "urn:s:%lu", i);
|
|
|
+ sprintf(pstr, "urn:p:%lu", i);
|
|
|
+ sprintf(ostr, "urn:o:%lu", i);
|
|
|
+ LSUP_triple_init(
|
|
|
+ trp + i, LSUP_uri_new (sstr),
|
|
|
+ LSUP_uri_new (pstr), LSUP_uri_new (ostr));
|
|
|
}
|
|
|
TRACE(STR, "Triples generated.");
|
|
|
|
|
|
- LSUP_Graph *gr;
|
|
|
- LSUP_graph_new(LSUP_STORE_MEM, &gr);
|
|
|
- LSUP_graph_resize(gr, nt);
|
|
|
+ return trp;
|
|
|
+}
|
|
|
+
|
|
|
+static LSUP_rc
|
|
|
+insert_triples (LSUP_Triple *trp)
|
|
|
+{
|
|
|
+ LSUP_Graph *gr = LSUP_graph_new(LSUP_STORE_MDB_TMP);
|
|
|
|
|
|
- LSUP_graph_add_trp(gr, trp, nt, NULL);
|
|
|
- TRACE(STR, "Graph populated.");
|
|
|
+ LSUP_rc rc = LSUP_graph_add_trp(gr, trp, NT, NULL);
|
|
|
+ if (rc != LSUP_OK) printf ("Graph loading interrupted: %d.\n", rc);
|
|
|
+ else printf ("Graph populated.\n");
|
|
|
|
|
|
LSUP_graph_free(gr);
|
|
|
|
|
|
- return 0;
|
|
|
+ return rc;
|
|
|
}
|
|
|
|
|
|
|
|
|
int main()
|
|
|
{
|
|
|
+ // Set env variable to test path.
|
|
|
+ putenv ("LSUP_MDB_STORE_PATH=" TMPDIR "/lsup_profile_mdb");
|
|
|
+ // Clear out database from previous test.
|
|
|
+ rm_r (getenv ("LSUP_MDB_STORE_PATH"));
|
|
|
+
|
|
|
int rc;
|
|
|
- clock_t start, end;
|
|
|
- double wallclock;
|
|
|
+ clock_t start, tc1, tc2;
|
|
|
+ double wallclock, rate;
|
|
|
|
|
|
start = clock();
|
|
|
- rc = test_graph_add_batch();
|
|
|
- end = clock();
|
|
|
-
|
|
|
- wallclock = (end - start) / CLOCKS_PER_SEC;
|
|
|
+ LSUP_Triple *trp = generate_triples();
|
|
|
+ tc1 = clock();
|
|
|
+ wallclock = (tc1 - start) / CLOCKS_PER_SEC;
|
|
|
+ printf("Time elapsed: %lf s\n", wallclock);
|
|
|
|
|
|
+ printf("Inserting triples.\n");
|
|
|
+ rc = insert_triples (trp);
|
|
|
+ tc2 = clock();
|
|
|
+ wallclock = (tc2 - tc1) / CLOCKS_PER_SEC;
|
|
|
printf("Time elapsed: %lf s\n", wallclock);
|
|
|
|
|
|
+ wallclock = (tc2 - start) / CLOCKS_PER_SEC;
|
|
|
+ rate = NT / wallclock;
|
|
|
+ printf(
|
|
|
+ "%d triples created and inserted in %lf s (%lf triples/s)\n",
|
|
|
+ NT, wallclock, rate);
|
|
|
+
|
|
|
return rc;
|
|
|
}
|