get results from memobin
2 changed files+16−52
scripts/run_benchmarks.pymodified+15−51View file
@@ -1,65 +1,16 @@
11 #!/usr/bin/env python3
22
33 import json
4+import os
45 from pathlib import Path
56 from benchcompress import run_benchmarks
6-
7-def format_size(size_bytes: float) -> str:
8- """Format size in bytes to human readable string"""
9- for unit in ['B', 'KB', 'MB', 'GB']:
10- if size_bytes < 1024:
11- return f"{size_bytes:.1f} {unit}"
12- size_bytes /= 1024
13- return f"{size_bytes:.1f} TB"
14-
15-def format_time(seconds: float) -> str:
16- """Format time in seconds to human readable string"""
17- if seconds < 0.001:
18- return f"{seconds * 1_000_000:.1f} µs"
19- if seconds < 1:
20- return f"{seconds * 1_000:.1f} ms"
21- return f"{seconds:.2f} s"
7+from benchcompress.run_benchmarks._memobin import upload_to_memobin, construct_memobin_url
228
239 def main():
2410 # Run benchmarks
2511 print("Running benchmarks...")
2612 results = run_benchmarks()
2713
28- # Group results by dataset
29- datasets = {}
30- for result in results['results']:
31- dataset_name = result['dataset']
32- if dataset_name not in datasets:
33- datasets[dataset_name] = []
34- datasets[dataset_name].append(result)
35-
36- # Print results
37- print("\nBenchmark Results:")
38- print("=================")
39-
40- for dataset_name, dataset_results in sorted(datasets.items()):
41- print(f"\nDataset: {dataset_name}")
42- print("-" * (len(dataset_name) + 9))
43- print(f"Original size: {format_size(dataset_results[0]['original_size'])}")
44-
45- # Sort algorithms by compression ratio
46- dataset_results.sort(key=lambda x: x['compression_ratio'], reverse=True)
47-
48- # Print table header
49- print("\n{:<15} {:>12} {:>12} {:>12}".format(
50- "Algorithm", "Ratio", "Encode", "Decode"
51- ))
52- print("-" * 53)
53-
54- # Print results for each algorithm
55- for result in dataset_results:
56- print("{:<15} {:>11.2f}x {:>12} {:>12}".format(
57- result['algorithm'],
58- result['compression_ratio'],
59- format_time(result['encode_time']),
60- format_time(result['decode_time'])
61- ))
62-
6314 # Save detailed results to JSON
6415 output_dir = Path("benchmark_results")
6516 output_dir.mkdir(exist_ok=True)
@@ -70,5 +21,18 @@ def main():
7021
7122 print(f"\nDetailed results saved to {output_file}")
7223
24+ # Upload results to memobin if enabled
25+ memobin_api_key = os.environ.get("MEMOBIN_API_KEY")
26+ upload_enabled = os.environ.get("UPLOAD_TO_MEMOBIN") == "1"
27+
28+ if memobin_api_key and upload_enabled:
29+ try:
30+ # Construct URL for the global results file
31+ url = "https://tempory.net/f/memobin/benchcompress/global/results.json"
32+ upload_to_memobin(results, url, memobin_api_key)
33+ print("Successfully uploaded results to memobin")
34+ except Exception as e:
35+ print(f"Warning: Failed to upload results to memobin: {str(e)}")
36+
7337 if __name__ == "__main__":
7438 main()
web-ui/src/App.tsxmodified+1−1View file
@@ -22,7 +22,7 @@ function App() {
2222 setIsLoading(true);
2323 setError(null);
2424 const response = await axios.get(
25- "https://raw.githubusercontent.com/magland/benchcompress/benchmark-results/benchmark_results/results.json",
25+ "https://tempory.net/f/memobin/benchcompress/global/results.json",
2626 );
2727 setBenchmarkData(response.data);
2828 } catch (error) {