12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include <time.h>
- #include "graph.h"
- #ifndef NT
- #define NT 100000
- #endif
- static LSUP_Triple *
- generate_triples()
- {
- LSUP_Triple *trp;
- trp = malloc(NT * sizeof(LSUP_Triple));
- if (!trp) exit (-1);
- 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.");
- return trp;
- }
- static LSUP_rc
- insert_triples (LSUP_Triple *trp)
- {
- LSUP_Graph *gr = LSUP_graph_new(LSUP_STORE_MDB_TMP);
- 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 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, tc1, tc2;
- double wallclock, rate;
- printf ("Generating triples.\n");
- start = clock();
- 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;
- }
|