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

Function cx_measure

tests/test_complexity.c:828–858  ·  view source on GitHub ↗

Build one corpus shape at k and 2k in two fresh temp dirs, run the pipeline * on both, and remove both dirs before returning — on success and on every * failure path. Only the metrics outlive the call; the corpora used to stay * behind in the temp root, four per suite run. Only dirs this call created * are removed (the temp root is shared with concurrent runs). */

Source from the content-addressed store, hash-verified

826 * behind in the temp root, four per suite run. Only dirs this call created
827 * are removed (the temp root is shared with concurrent runs). */
828static int cx_measure(CxCorpusBuilder build, const char *prefix_a, const char *prefix_b,
829 CxMetrics *out_a, CxMetrics *out_b) {
830 const char *tmp = cbm_tmpdir();
831 char root_a[512];
832 char root_b[512];
833 int na = snprintf(root_a, sizeof(root_a), "%s/%s_XXXXXX", tmp, prefix_a);
834 int nb = snprintf(root_b, sizeof(root_b), "%s/%s_XXXXXX", tmp, prefix_b);
835 if (na < 0 || (size_t)na >= sizeof(root_a) || nb < 0 || (size_t)nb >= sizeof(root_b))
836 return -1;
837 bool made_a = cbm_mkdtemp(root_a) != NULL;
838 bool made_b = made_a && cbm_mkdtemp(root_b) != NULL;
839 int rc = -1;
840 if (made_b && build(root_a, CX_K_BASE) == 0 && build(root_b, CX_K_BASE * 2) == 0) {
841 char db_a[600];
842 char db_b[600];
843 int da = snprintf(db_a, sizeof(db_a), "%s/cx.db", root_a);
844 int db = snprintf(db_b, sizeof(db_b), "%s/cx.db", root_b);
845 bool paths = da >= 0 && (size_t)da < sizeof(db_a) && db >= 0 && (size_t)db < sizeof(db_b);
846 bool pyext = build == cx_build_pyext;
847 bool pyrange = build == cx_build_pyrange;
848 if (paths && cx_run(root_a, db_a, out_a, pyext, pyrange) == 0 &&
849 cx_run(root_b, db_b, out_b, pyext, pyrange) == 0) {
850 rc = 0;
851 }
852 }
853 if (made_b && cx_remove_corpus(root_b) != 0 && build == cx_build_pyrange)
854 rc = -1;
855 if (made_a && cx_remove_corpus(root_a) != 0 && build == cx_build_pyrange)
856 rc = -1;
857 return rc;
858}
859
860/* Shared across the suite so the report test reuses the measured pair instead
861 * of paying two more pipeline runs. */

Callers 3

cx_measure_pairFunction · 0.85
cx_measure_bigpkg_pairFunction · 0.85
test_complexity.cFile · 0.85

Calls 5

cbm_tmpdirFunction · 0.85
cbm_mkdtempFunction · 0.85
buildFunction · 0.85
cx_runFunction · 0.85
cx_remove_corpusFunction · 0.85

Tested by

no test coverage detected