add lzma and control upload to memobin
4 changed files+31−4
.github/workflows/benchmark.ymlmodified+1−0View file
@@ -29,6 +29,7 @@ jobs:
2929 - name: Run benchmarks
3030 env:
3131 MEMOBIN_API_KEY: ${{ secrets.MEMOBIN_API_KEY }}
32+ UPLOAD_TO_MEMOBIN: '1'
3233 run: |
3334 python scripts/run_benchmarks.py
3435
zia_benchmark/src/zia_benchmark/algorithms/__init__.pymodified+2−1View file
@@ -1,5 +1,6 @@
11 from .zlib import algorithms as zlib_algorithms
22 from .zstd import algorithms as zstd_algorithms
33 from .simple_ans import algorithms as simple_ans_algorithms
4+from .lzma import algorithms as lzma_algorithms
45
5-algorithms = zlib_algorithms + zstd_algorithms + simple_ans_algorithms
6+algorithms = zlib_algorithms + zstd_algorithms + simple_ans_algorithms + lzma_algorithms
zia_benchmark/src/zia_benchmark/algorithms/lzma/__init__.pyadded+24−0View file
@@ -0,0 +1,24 @@
1+import numpy as np
2+
3+
4+def lzma_encode(x: np.ndarray, preset: int) -> bytes:
5+ import lzma
6+ assert x.ndim == 1
7+ buf = x.tobytes()
8+ compressed = lzma.compress(buf, preset=preset)
9+ return compressed
10+
11+def lzma_decode(x: bytes, dtype: str) -> np.ndarray:
12+ import lzma
13+ buf = lzma.decompress(x)
14+ y = np.frombuffer(buf, dtype=dtype)
15+ return y
16+
17+algorithms = [
18+ {
19+ 'name': 'lzma-9',
20+ 'version': '1',
21+ 'encode': lambda x: lzma_encode(x, preset=9),
22+ 'decode': lambda x, dtype: lzma_decode(x, dtype)
23+ }
24+]
zia_benchmark/src/zia_benchmark/run_benchmarks.pymodified+4−3View file
@@ -9,7 +9,7 @@ from .datasets import datasets
99 from ._memobin import construct_memobin_url, upload_to_memobin, download_from_memobin
1010
1111
12-system_version = 'v3'
12+system_version = 'v4'
1313
1414 def run_benchmarks(cache_dir: str = '.benchmark_cache', verbose: bool = True) -> Dict[str, Any]:
1515 """Run all benchmarks, with caching based on algorithm and dataset versions.
@@ -163,9 +163,10 @@ def run_benchmarks(cache_dir: str = '.benchmark_cache', verbose: bool = True) ->
163163 f.write(encoded)
164164 print(f" Results saved to: {test_dir}")
165165
166- # Upload to memobin if API key is set
166+ # Upload to memobin if API key is set and upload is enabled
167167 memobin_api_key = os.environ.get('MEMOBIN_API_KEY')
168- if memobin_api_key:
168+ upload_enabled = os.environ.get('UPLOAD_TO_MEMOBIN') == '1'
169+ if memobin_api_key and upload_enabled:
169170 if verbose:
170171 print(" Uploading results to memobin...")
171172 try: