/ concept-collection / benchcompress
concept-collection / benchcompress
benchcompress / scripts / run_benchmarks.py
38 lines · 1.2 KBBlameHistoryRaw
1#!/usr/bin/env python3
3import json
4import os
5from pathlib import Path
6from benchcompress import run_benchmarks
7from benchcompress.run_benchmarks._memobin import upload_to_memobin, construct_memobin_url
9def main():
10 # Run benchmarks
11 print("Running benchmarks...")
12 results = run_benchmarks()
14 # Save detailed results to JSON
15 output_dir = Path("benchmark_results")
16 output_dir.mkdir(exist_ok=True)
17 output_file = output_dir / "results.json"
19 with open(output_file, "w") as f:
20 json.dump(results, f, indent=2)
22 print(f"\nDetailed results saved to {output_file}")
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"
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)}")
37if __name__ == "__main__":
38 main()