profile.c 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. LSUP_uri_new (NULL, trp[i].s);
  14. LSUP_uri_new (NULL, trp[i].p);
  15. LSUP_uri_new (NULL, trp[i].o);
  16. }
  17. TRACE(STR, "Triples generated.");
  18. LSUP_Graph *gr;
  19. LSUP_graph_new(LSUP_STORE_MEM, &gr);
  20. LSUP_graph_resize(gr, nt);
  21. LSUP_graph_add_trp(gr, trp, nt, NULL);
  22. TRACE(STR, "Graph populated.");
  23. LSUP_graph_free(gr);
  24. return 0;
  25. }
  26. int main()
  27. {
  28. int rc;
  29. clock_t start, end;
  30. double wallclock;
  31. start = clock();
  32. rc = test_graph_add_batch();
  33. end = clock();
  34. wallclock = (end - start) / CLOCKS_PER_SEC;
  35. printf("Time elapsed: %lf s\n", wallclock);
  36. return rc;
  37. }