MCPcopy Create free account
hub / github.com/modem-dev/hunk / findPreviousReleaseBenchmark

Function findPreviousReleaseBenchmark

scripts/compare-release-benchmarks.ts:100–131  ·  view source on GitHub ↗
(version: string, directory = releaseBenchmarkDir())

Source from the content-addressed store, hash-verified

98
99/** Find the latest stable benchmark snapshot lower than the release candidate version. */
100export function findPreviousReleaseBenchmark(version: string, directory = releaseBenchmarkDir()) {
101 const current = parseReleaseVersion(version);
102 if (!existsSync(directory)) {
103 return undefined;
104 }
105
106 const candidates = readdirSync(directory)
107 .map((fileName) => {
108 const match = BENCHMARK_FILE_PATTERN.exec(fileName);
109 if (!match) {
110 return undefined;
111 }
112
113 const candidateVersion = parseReleaseVersion(match[1]!);
114 if (candidateVersion.prerelease) {
115 return undefined;
116 }
117
118 if (compareReleaseVersions(candidateVersion.raw, current.raw) >= 0) {
119 return undefined;
120 }
121
122 return {
123 version: candidateVersion.raw,
124 path: path.join(directory, fileName),
125 };
126 })
127 .filter((candidate): candidate is { version: string; path: string } => Boolean(candidate))
128 .sort((left, right) => compareReleaseVersions(right.version, left.version));
129
130 return candidates[0];
131}
132
133/** Read and lightly validate one benchmark JSON file. */
134export async function loadBenchmarkRun(filePath: string): Promise<BenchmarkRunResult> {

Callers 2

mainFunction · 0.85

Calls 3

releaseBenchmarkDirFunction · 0.85
parseReleaseVersionFunction · 0.85
compareReleaseVersionsFunction · 0.85

Tested by

no test coverage detected