perf: reduce renderer and repository polling work
ForgeFlow quality gate / quality (push) Canceled after 0s
ForgeFlow quality gate / quality (push) Canceled after 0s
This commit is contained in:
@@ -28,3 +28,24 @@ test('repository monitor establishes a baseline and emits only on later changes'
|
||||
await monitor.tick();
|
||||
assert.equal(changes.length, 2);
|
||||
});
|
||||
test('repository monitor checks multiple repositories concurrently with a bounded worker pool', async () => {
|
||||
let active = 0;
|
||||
let peak = 0;
|
||||
const git = {
|
||||
status: async (localPath) => {
|
||||
active += 1;
|
||||
peak = Math.max(peak, active);
|
||||
await new Promise((resolve) => setTimeout(resolve, 15));
|
||||
active -= 1;
|
||||
return { localPath, revision: 1 };
|
||||
},
|
||||
statusFingerprint: (status) => String(status.revision)
|
||||
};
|
||||
const store = { data: { preferences: { autoRefresh: true, repositoryPollSeconds: 2 } } };
|
||||
const monitor = new RepositoryMonitor({ store, git });
|
||||
monitor.setPaths(Array.from({ length: 10 }, (_, index) => `/repo-${index}`));
|
||||
await monitor.tick();
|
||||
assert.equal(peak, 4);
|
||||
assert.equal(active, 0);
|
||||
assert.equal(monitor.fingerprints.size, 10);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user