profile.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <time.h>
  2. #include "graph.h"
  3. #ifndef NT
  4. #define NT 1000000
  5. #endif
  6. static int test_graph_add_batch()
  7. {
  8. size_t nt = NT;
  9. LSUP_Triple *trp;
  10. CRITICAL(trp = malloc(nt * sizeof(LSUP_Triple)));
  11. for (size_t i = 0; i < nt; i++) {
  12. //printf("i: %lu\n", i);
  13. trp[i].s = LSUP_term_new(
  14. LSUP_TERM_URI, LSUP_term_gen_random_str(), NULL, NULL);
  15. trp[i].p = LSUP_term_new(
  16. LSUP_TERM_URI, LSUP_term_gen_random_str(), NULL, NULL);
  17. trp[i].o = LSUP_term_new(
  18. LSUP_TERM_URI, LSUP_term_gen_random_str(), NULL, NULL);
  19. }
  20. TRACE(STR, "Triples generated.");
  21. LSUP_Graph *gr = LSUP_graph_new(nt, NULL, LSUP_STORE_MEM);
  22. LSUP_graph_add(gr, trp, nt);
  23. TRACE(STR, "Graph populated.");
  24. LSUP_graph_free(gr);
  25. return 0;
  26. }
  27. int main()
  28. {
  29. int rc;
  30. clock_t start, end;
  31. double wallclock;
  32. start = clock();
  33. rc = test_graph_add_batch();
  34. end = clock();
  35. wallclock = (end - start) / CLOCKS_PER_SEC;
  36. printf("Time elapsed: %lf s\n", wallclock);
  37. return rc;
  38. }