Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ const { srcDir, cleanup } = await resolveBenchmarkSource();

const dbPath = path.join(root, '.codegraph', 'graph.db');

const { buildGraph } = await import(srcImport(srcDir, 'builder.js'));
const { buildGraph } = await import(srcImport(srcDir, 'domain/graph/builder.js'));
const { fnDepsData, fnImpactData, pathData, rolesData, statsData } = await import(
srcImport(srcDir, 'queries.js')
srcImport(srcDir, 'domain/queries.js')
);

const INCREMENTAL_RUNS = 3;
const QUERY_RUNS = 5;
const PROBE_FILE = path.join(root, 'src', 'queries.js');
const PROBE_FILE = path.join(root, 'src', 'domain', 'queries.js');

function median(arr) {
const sorted = [...arr].sort((a, b) => a - b);
Expand Down
4 changes: 2 additions & 2 deletions scripts/embedding-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (process.env[MODEL_WORKER_KEY]) {
const dbPath = path.join(root, '.codegraph', 'graph.db');

const { buildEmbeddings, MODELS, searchData, disposeModel } = await import(
srcImport(srcDir, 'embeddings/index.js')
srcImport(srcDir, 'domain/search/index.js')
);

const TEST_PATTERN = /\.(test|spec)\.|__test__|__tests__|\.stories\./;
Expand Down Expand Up @@ -123,7 +123,7 @@ if (process.env[MODEL_WORKER_KEY]) {
const { version, srcDir, cleanup } = await resolveBenchmarkSource();
const dbPath = path.join(root, '.codegraph', 'graph.db');

const { MODELS } = await import(srcImport(srcDir, 'embeddings/index.js'));
const { MODELS } = await import(srcImport(srcDir, 'domain/search/index.js'));

const TIMEOUT_MS = 600_000;
const hasHfToken = !!process.env.HF_TOKEN;
Expand Down
30 changes: 17 additions & 13 deletions scripts/incremental-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ if (!isWorker()) {
const rootParent = path.resolve(__dirParent, '..');
const dbPathParent = path.join(rootParent, '.codegraph', 'graph.db');

const { statsData: parentStats } = await import(srcImport(parentSrcDir, 'queries.js'));
const { statsData: parentStats } = await import(srcImport(parentSrcDir, 'domain/queries.js'));
const { resolveImportsBatch: parentBatch, resolveImportPathJS: parentJS } = await import(
srcImport(parentSrcDir, 'resolve.js')
srcImport(parentSrcDir, 'domain/graph/resolve.js')
);
const { isNativeAvailable: parentNativeCheck } = await import(
srcImport(parentSrcDir, 'native.js')
srcImport(parentSrcDir, 'infrastructure/native.js')
);

const RUNS = 3;
Expand All @@ -52,18 +52,22 @@ if (!isWorker()) {
function round1(n) { return Math.round(n * 10) / 10; }

function collectImportPairs() {
const srcDir = path.join(rootParent, 'src');
const files = fs.readdirSync(srcDir).filter((f) => f.endsWith('.js'));
const srcRoot = path.join(rootParent, 'src');
const importRe = /(?:^|\n)\s*import\s+.*?\s+from\s+['"]([^'"]+)['"]/g;
const pairs = [];
for (const file of files) {
const absFile = path.join(srcDir, file);
const content = fs.readFileSync(absFile, 'utf8');
let match;
while ((match = importRe.exec(content)) !== null) {
pairs.push({ fromFile: absFile, importSource: match[1] });
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
if (entry.isDirectory()) { walk(path.join(dir, entry.name)); continue; }
if (!entry.name.endsWith('.js')) continue;
const absFile = path.join(dir, entry.name);
const content = fs.readFileSync(absFile, 'utf8');
let match;
while ((match = importRe.exec(content)) !== null) {
pairs.push({ fromFile: absFile, importSource: match[1] });
}
}
}
walk(srcRoot);
return pairs;
}

Expand Down Expand Up @@ -138,14 +142,14 @@ const root = path.resolve(__dirname, '..');
const { srcDir, cleanup } = await resolveBenchmarkSource();
const dbPath = path.join(root, '.codegraph', 'graph.db');

const { buildGraph } = await import(srcImport(srcDir, 'builder.js'));
const { buildGraph } = await import(srcImport(srcDir, 'domain/graph/builder.js'));

// Redirect console.log to stderr so only JSON goes to stdout
const origLog = console.log;
console.log = (...args) => console.error(...args);

const RUNS = 3;
const PROBE_FILE = path.join(root, 'src', 'queries.js');
const PROBE_FILE = path.join(root, 'src', 'domain', 'queries.js');

function median(arr) {
const sorted = [...arr].sort((a, b) => a - b);
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/fork-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ export async function forkEngines(scriptUrl, argv = [], opts = {}) {
const { srcDir, cleanup } = await resolveBenchmarkSource();

try {
const { isWasmAvailable } = await import(srcImport(srcDir, 'parser.js'));
const { isWasmAvailable } = await import(srcImport(srcDir, 'domain/parser.js'));
hasWasm = isWasmAvailable();
} catch { /* unavailable */ }

try {
const { isNativeAvailable } = await import(srcImport(srcDir, 'native.js'));
const { isNativeAvailable } = await import(srcImport(srcDir, 'infrastructure/native.js'));
hasNative = isNativeAvailable();
} catch { /* unavailable */ }

Expand Down
4 changes: 2 additions & 2 deletions scripts/query-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const root = path.resolve(__dirname, '..');
const { srcDir, cleanup } = await resolveBenchmarkSource();
const dbPath = path.join(root, '.codegraph', 'graph.db');

const { buildGraph } = await import(srcImport(srcDir, 'builder.js'));
const { buildGraph } = await import(srcImport(srcDir, 'domain/graph/builder.js'));
const { fnDepsData, fnImpactData, diffImpactData } = await import(
srcImport(srcDir, 'queries.js')
srcImport(srcDir, 'domain/queries.js')
);

// Redirect console.log to stderr so only JSON goes to stdout
Expand Down
Loading