Skip to content

Commit 5878bf9

Browse files
committed
Only load benchmark names when needed
1 parent abe1c88 commit 5878bf9

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

frontend/src/app/build-comparison/page.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default function BuildComparisonPage() {
8282
const [loading, setLoading] = useState(true);
8383
const [error, setError] = useState<string | null>(null);
8484
const [dataProcessing, setDataProcessing] = useState(false);
85+
const [benchmarkNamesLoading, setBenchmarkNamesLoading] = useState(false);
8586

8687
// Store trend data for each binary-benchmark combination
8788
const [trendData, setTrendData] = useState<
@@ -177,10 +178,8 @@ export default function BuildComparisonPage() {
177178
async function loadBenchmarkData() {
178179
if (
179180
!selectedEnvironmentId ||
180-
!selectedPythonVersionKey ||
181-
selectedBinaries.length === 0
181+
!selectedPythonVersionKey
182182
) {
183-
setDataProcessing(false);
184183
return;
185184
}
186185

@@ -193,12 +192,17 @@ export default function BuildComparisonPage() {
193192
}
194193

195194
try {
196-
setDataProcessing(true);
195+
setBenchmarkNamesLoading(true);
197196

198-
// Get available benchmark names for the first binary
197+
// Get available benchmark names for the first available binary (benchmark names are the same across binaries)
198+
const firstBinaryId = binaries.length > 0 ? binaries[0].id : undefined;
199+
if (!firstBinaryId) {
200+
return;
201+
}
202+
199203
const uniqueBenchmarks = await api.getBenchmarkNames({
200204
environment_id: selectedEnvironmentId,
201-
binary_id: selectedBinaries[0],
205+
binary_id: firstBinaryId,
202206
python_major: versionOption.major,
203207
python_minor: versionOption.minor,
204208
} satisfies BenchmarkNamesQueryParams);
@@ -217,7 +221,7 @@ export default function BuildComparisonPage() {
217221
variant: 'destructive',
218222
});
219223
} finally {
220-
setDataProcessing(false);
224+
setBenchmarkNamesLoading(false);
221225
}
222226
}
223227

@@ -227,10 +231,10 @@ export default function BuildComparisonPage() {
227231
}, [
228232
selectedEnvironmentId,
229233
selectedPythonVersionKey,
230-
selectedBinaries,
231234
pythonVersionOptions,
232235
loading,
233236
mounted,
237+
binaries,
234238
]);
235239

236240
// Load ALL benchmark data upfront for selected binaries and environment
@@ -1067,12 +1071,7 @@ export default function BuildComparisonPage() {
10671071
}
10681072
/>
10691073
<ScrollArea className="h-48 rounded-md border p-4">
1070-
{loading ||
1071-
dataProcessing ||
1072-
(allBenchmarkNames.length === 0 &&
1073-
selectedEnvironmentId &&
1074-
selectedPythonVersionKey &&
1075-
selectedBinaries.length > 0) ? (
1074+
{benchmarkNamesLoading ? (
10761075
<div className="space-y-2">
10771076
{[...Array(8)].map((_, i) => (
10781077
<div key={i} className="flex items-center space-x-2">

frontend/src/app/trends/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default function BenchmarkTrendPage() {
8282
const [loading, setLoading] = useState(true);
8383
const [error, setError] = useState<string | null>(null);
8484
const [dataProcessing, setDataProcessing] = useState(false);
85+
const [benchmarkNamesLoading, setBenchmarkNamesLoading] = useState(false);
8586

8687
const [selectedBinaryId, setSelectedBinaryId] = useState<
8788
string | undefined
@@ -232,7 +233,7 @@ export default function BenchmarkTrendPage() {
232233
}
233234

234235
try {
235-
setDataProcessing(true);
236+
setBenchmarkNamesLoading(true);
236237
const uniqueBenchmarks = await api.getBenchmarkNames({
237238
environment_id: selectedEnvironmentId,
238239
binary_id: selectedBinaryId,
@@ -254,11 +255,11 @@ export default function BenchmarkTrendPage() {
254255
variant: 'destructive',
255256
});
256257
} finally {
257-
setDataProcessing(false);
258+
setBenchmarkNamesLoading(false);
258259
}
259260
}
260261

261-
if (!loading && mounted && availableEnvironments.length > 0) {
262+
if (!loading && mounted) {
262263
loadBenchmarkData();
263264
}
264265
}, [
@@ -268,7 +269,6 @@ export default function BenchmarkTrendPage() {
268269
pythonVersionOptions,
269270
loading,
270271
mounted,
271-
availableEnvironments,
272272
]);
273273

274274
// Load trend data when benchmarks are selected
@@ -826,7 +826,7 @@ export default function BenchmarkTrendPage() {
826826
disabled={loading || allBenchmarkNames.length === 0}
827827
/>
828828
<ScrollArea className="h-40 rounded-md border p-2">
829-
{loading || dataProcessing ? (
829+
{benchmarkNamesLoading ? (
830830
<div className="space-y-2">
831831
{[...Array(6)].map((_, i) => (
832832
<div key={i} className="flex items-center space-x-2">

0 commit comments

Comments
 (0)