import { Link, useLocation, useParams } from "react-router-dom"; import { BenchmarkTable } from "../components/benchmark/table/BenchmarkTable"; import { useEffect, useRef, useState } from "react"; import TimeseriesView from "../components/dataset/TimeseriesView"; import { BenchmarkCharts } from "../components/benchmark/charts/BenchmarkCharts"; import { useBenchmarkChartData } from "../hooks/useBenchmarkChartData"; import { TagFilter } from "../components/TagFilter"; import { useTagFilter } from "../hooks/useTagFilter"; import { BenchmarkData } from "../types"; interface HomeProps { benchmarkData: BenchmarkData | null; } export default function Home({ benchmarkData }: HomeProps) { const location = useLocation(); const { datasetName, algorithmName } = useParams<{ datasetName?: string; algorithmName?: string; }>(); const containerRef = useRef(null); const [containerWidth, setContainerWidth] = useState(1200); useEffect(() => { if (!containerRef.current) return; const resizeObserver = new ResizeObserver((entries) => { for (const entry of entries) { setContainerWidth(entry.contentRect.width - 32); } }); resizeObserver.observe(containerRef.current); return () => { resizeObserver.disconnect(); }; }, []); // Determine active tab based on URL const getActiveTab = () => { if (datasetName) return `dataset-${datasetName}`; if (algorithmName) return `algorithm-${algorithmName}`; if (location.pathname.includes("/algorithms")) return "algorithms"; return "datasets"; }; const activeTab = getActiveTab(); // Get specific dataset or algorithm if viewing one const dataset = datasetName ? benchmarkData?.datasets.find((d) => d.name === datasetName) : undefined; const algorithm = algorithmName ? benchmarkData?.algorithms.find((a) => a.name === algorithmName) : undefined; // Get chart data for specific dataset or algorithm view const chartData = useBenchmarkChartData( benchmarkData?.results || [], dataset?.name || null, algorithm?.name || null, ); // Set up tag filtering for datasets const { selectedTags: datasetTags, availableTags: availableDatasetTags, filteredItems: filteredDatasets, toggleTag: toggleDatasetTag, } = useTagFilter(benchmarkData?.datasets || []); // Set up tag filtering for algorithms const { selectedTags: algorithmTags, availableTags: availableAlgorithmTags, filteredItems: filteredAlgorithms, toggleTag: toggleAlgorithmTag, } = useTagFilter(benchmarkData?.algorithms || []); const renderDatasets = () => (
{filteredDatasets.map((dataset, index) => ( ))}
Name Version Description Tags Source Data
{dataset.name} {dataset.version} {dataset.description} {dataset.tags.map((tag) => ( {tag} ))} {dataset.source_file && ( View Source )} {dataset.data_url_npy && ( Download )}
); const renderAlgorithms = () => (
{filteredAlgorithms.map((algorithm, index) => ( ))}
Name Version Description Tags Source
{algorithm.name} {algorithm.version} {algorithm.description} {algorithm.tags.map((tag) => ( {tag} ))} {algorithm.source_file && ( View Source )}
); return (

Benchcompress

Comparing compression algorithms for numeric arrays

Datasets Algorithms {dataset && ( {dataset.name} )} {algorithm && ( {algorithm.name} )}
{dataset ? (

{dataset.description}

Version:{" "} {dataset.version}
Tags:{" "} {dataset.tags.map((tag) => ( {tag} ))}
Download:{" "} {dataset.data_url_npy && ( NPY )} {dataset.data_url_raw && ( RAW )}
{dataset.source_file && (
Source:{" "} View
)}
{benchmarkData && ( <>

Benchmark Results

result.dataset === dataset.name, )} />
)}
) : algorithm ? (

{algorithm.description}

Version:{" "} {algorithm.version}
Tags:{" "} {algorithm.tags.map((tag) => ( {tag} ))}
{algorithm.source_file && (
Source:{" "} View
)}
{benchmarkData && ( <>

Benchmark Results

result.algorithm === algorithm.name, )} />
)}
) : activeTab === "datasets" ? ( renderDatasets() ) : ( renderAlgorithms() )}
); }