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

Function build_fixture

tests/test_py_lsp_scale.c:18–48  ·  view source on GitHub ↗

Build N synthetic class/call pairs into an arena-backed buffer. */

Source from the content-addressed store, hash-verified

16
17/* Build N synthetic class/call pairs into an arena-backed buffer. */
18static char *build_fixture(int n_classes, int *out_len) {
19 /* Per class: ~140 chars (5-line def). Per call: ~50 chars. Overhead
20 * for the class number digits scales with log10(n) but the constant
21 * 256 covers up to 9-digit indices comfortably. */
22 int approx = n_classes * 256 + 1024;
23 char *buf = (char *)malloc((size_t)approx);
24 if (!buf) return NULL;
25 int pos = 0;
26 pos += snprintf(buf + pos, (size_t)(approx - pos),
27 "from typing import Self\n");
28 for (int i = 0; i < n_classes; i++) {
29 int n = snprintf(buf + pos, (size_t)(approx - pos),
30 "class Cls%d:\n"
31 " def method(self) -> int:\n"
32 " return %d\n"
33 " def chain(self) -> Self:\n"
34 " return self\n", i, i);
35 if (n < 0 || pos + n >= approx) break;
36 pos += n;
37 }
38 int n = snprintf(buf + pos, (size_t)(approx - pos), "def use():\n");
39 pos += n;
40 for (int i = 0; i < n_classes; i++) {
41 int m = snprintf(buf + pos, (size_t)(approx - pos),
42 " Cls%d().chain().chain().method()\n", i);
43 if (m < 0 || pos + m >= approx) break;
44 pos += m;
45 }
46 *out_len = pos;
47 return buf;
48}
49
50static double measure(int n_classes, int *out_calls, int *out_resolved) {
51 int slen = 0;

Callers 1

measureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected