|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import sys |
| 4 | +import subprocess |
| 5 | +import argparse |
| 6 | + |
| 7 | + |
| 8 | +def run_command(cmd): |
| 9 | + """Run a shell command and print output""" |
| 10 | + print(f"Running: {' '.join(cmd)}") |
| 11 | + try: |
| 12 | + subprocess.run(cmd, check=True) |
| 13 | + except subprocess.CalledProcessError as e: |
| 14 | + print(f"Error: Command '{' '.join(cmd)}' failed with return code {e.returncode}") |
| 15 | + print(f"Output: {e.output.decode('utf-8') if e.output else 'No output'}") |
| 16 | + sys.exit(1) |
| 17 | + |
| 18 | +def main(): |
| 19 | + # Set up argument parsing |
| 20 | + parser = argparse.ArgumentParser(description='Run Blitzar benchmarks') |
| 21 | + parser.add_argument('device', choices=['cpu', 'gpu'], help='Device to run benchmarks on') |
| 22 | + args = parser.parse_args() |
| 23 | + |
| 24 | + # Define benchmark parameters |
| 25 | + sizes = [10000, 100000, 1000000] |
| 26 | + num_samples = 10 |
| 27 | + num_commitments = [1, 10] |
| 28 | + element_nbytes = [1, 32] |
| 29 | + verbose = 0 |
| 30 | + |
| 31 | + # Multi commitment benchmark |
| 32 | + for commitment in num_commitments: |
| 33 | + for nbytes in element_nbytes: |
| 34 | + for size in sizes: |
| 35 | + cmd = [ |
| 36 | + "bazel", "run", "-c", "opt", "//benchmark/multi_commitment:benchmark", "--", |
| 37 | + args.device, str(size), str(num_samples), str(commitment), str(nbytes), str(verbose) |
| 38 | + ] |
| 39 | + run_command(cmd) |
| 40 | + |
| 41 | + # Inner product proof benchmark |
| 42 | + for size in sizes: |
| 43 | + cmd = [ |
| 44 | + "bazel", "run", "-c", "opt", "//benchmark/inner_product_proof:benchmark", "--", |
| 45 | + args.device, str(size), str(num_samples) |
| 46 | + ] |
| 47 | + run_command(cmd) |
| 48 | + |
| 49 | + |
| 50 | +if __name__ == "__main__": |
| 51 | + main() |
0 commit comments