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

Function work_for

tests/test_py_lsp.c:2369–2383  ·  view source on GitHub ↗

Deterministic complexity gate (#1527, O9: no clock). The resolver * primitives count every candidate they examine -- scope-frame probes, * registry lookup probes, enclosing-definition candidates -- plus every real * (non-memoized) expression evaluation, into a seam-build work counter. 4x * the input must cost about 4x the work: a linear-scan lookup or a lost memo * lands at ~16x (quadratic) o

Source from the content-addressed store, hash-verified

2367 * lands at ~16x (quadratic) or worse. Also asserts every call site resolved,
2368 * so the work is not "linear" because resolution stopped early. */
2369static uint64_t work_for(int n_classes, int *out_resolved) {
2370 int slen = 0;
2371 char *src = pylsp_work_fixture(n_classes, &slen);
2372 if (!src)
2373 return 0;
2374 (void)cbm_lsp_work_take();
2375 CBMFileResult *r =
2376 cbm_extract_file(src, slen, CBM_LANG_PYTHON, "test", "scale.py", 0, NULL, NULL);
2377 uint64_t work = cbm_lsp_work_take();
2378 *out_resolved = r ? r->resolved_calls.count : -1;
2379 if (r)
2380 cbm_free_result(r);
2381 free(src);
2382 return work;
2383}
2384
2385TEST(pylsp_scale_work_is_linear) {
2386 int r1 = 0, r4 = 0;

Callers 1

test_py_lsp.cFile · 0.85

Calls 4

pylsp_work_fixtureFunction · 0.85
cbm_lsp_work_takeFunction · 0.85
cbm_extract_fileFunction · 0.85
cbm_free_resultFunction · 0.85

Tested by

no test coverage detected