MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / timed_boundaries_ms

Function timed_boundaries_ms

tests/test_store_arch.c:451–504  ·  view source on GitHub ↗

Build a synthetic graph (nodes Functions across packages, random CALLS * edges) and return the wall ms of the "boundaries" aspect. Returns -1 on * setup/query failure. */

Source from the content-addressed store, hash-verified

449 * edges) and return the wall ms of the "boundaries" aspect. Returns -1 on
450 * setup/query failure. */
451static double timed_boundaries_ms(int n_nodes, int n_edges, int n_pkgs) {
452 cbm_store_t *s = cbm_store_open_memory();
453 if (!s) {
454 return -1;
455 }
456 cbm_store_upsert_project(s, "perf", "/tmp/perf");
457
458 cbm_store_begin(s);
459 int64_t *ids = malloc((size_t)n_nodes * sizeof(int64_t));
460 if (!ids) {
461 cbm_store_close(s);
462 return -1;
463 }
464 for (int i = 0; i < n_nodes; i++) {
465 char name[32], qn[64];
466 snprintf(name, sizeof(name), "fn%d", i);
467 snprintf(qn, sizeof(qn), "perf.pkg%d.fn%d", i % n_pkgs, i);
468 cbm_node_t n = {.project = "perf",
469 .label = "Function",
470 .name = name,
471 .qualified_name = qn,
472 .file_path = "f.c"};
473 ids[i] = cbm_store_upsert_node(s, &n);
474 }
475 uint64_t rng = 42;
476 for (int i = 0; i < n_edges; i++) {
477 rng = rng * 6364136223846793005ULL + 1442695040888963407ULL;
478 int a = (int)((rng >> 33) % (uint64_t)n_nodes);
479 rng = rng * 6364136223846793005ULL + 1442695040888963407ULL;
480 int b = (int)((rng >> 33) % (uint64_t)n_nodes);
481 cbm_edge_t e = {
482 .project = "perf", .source_id = ids[a], .target_id = ids[b], .type = "CALLS"};
483 cbm_store_insert_edge(s, &e);
484 }
485 cbm_store_commit(s);
486 free(ids);
487
488 cbm_architecture_info_t info;
489 memset(&info, 0, sizeof(info));
490 const char *aspects[] = {"boundaries"};
491 struct timespec t0, t1;
492 clock_gettime(CLOCK_MONOTONIC, &t0);
493 int rc = cbm_store_get_architecture(s, "perf", NULL, aspects, 1, &info);
494 clock_gettime(CLOCK_MONOTONIC, &t1);
495 double ms =
496 (double)(t1.tv_sec - t0.tv_sec) * 1000.0 + (double)(t1.tv_nsec - t0.tv_nsec) / 1000000.0;
497 int bcount = info.boundary_count;
498 cbm_store_architecture_free(&info);
499 cbm_store_close(s);
500 if (rc != CBM_STORE_OK || bcount <= 0) {
501 return -1;
502 }
503 return ms;
504}
505
506/* arch_boundaries used a LINEAR SCAN over all def nodes for EVERY CALLS edge
507 * (lookup_pkg over parallel arrays) — O(E×N). On the Linux kernel graph

Callers 1

test_store_arch.cFile · 0.85

Calls 9

cbm_store_open_memoryFunction · 0.85
cbm_store_upsert_projectFunction · 0.85
cbm_store_beginFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_store_upsert_nodeFunction · 0.85
cbm_store_insert_edgeFunction · 0.85
cbm_store_commitFunction · 0.85

Tested by

no test coverage detected