kangaroo 0.1.0

Pollard's Kangaroo ECDLP solver for secp256k1 using Vulkan/Metal/DX12 compute
Documentation
import os
import sys

import matplotlib.pyplot as plt
import pandas as pd


def analyze_results(csv_file):
    if not os.path.exists(csv_file):
        print(f"File {csv_file} not found.")
        return

    df = pd.read_csv(csv_file)

    print("=== Benchmark Analysis ===")
    print(f"Total runs: {len(df)}")

    # Success rate by strategy
    success_rate = df.groupby("strategy")["success"].mean()
    print("\nSuccess Rate by Strategy:")
    print(success_rate)

    # Average steps by strategy (only successful runs)
    avg_steps = df[df["success"] == True].groupby("strategy")["steps"].mean()
    print("\nAverage Steps (Successful runs):")
    print(avg_steps)

    # Average time
    avg_time = df.groupby("strategy")["time_ms"].mean()
    print("\nAverage Time (ms):")
    print(avg_time)

    # Pivot table
    summary = df.pivot_table(
        index="strategy",
        values=["steps", "time_ms", "success"],
        aggfunc={"steps": "mean", "time_ms": "mean", "success": "mean"},
    )
    print("\nSummary Table:")
    print(summary)

    # Create simple plots if matplotlib is installed
    try:
        plt.figure(figsize=(10, 6))
        summary["success"].plot(kind="bar", title="Success Rate by Strategy")
        plt.tight_layout()
        plt.savefig("success_rate.png")
        print("Saved success_rate.png")

        plt.figure(figsize=(10, 6))
        summary["steps"].plot(kind="bar", title="Avg Steps to Solve")
        plt.tight_layout()
        plt.savefig("avg_steps.png")
        print("Saved avg_steps.png")

    except Exception as e:
        print(f"Could not save plots: {e}")


if __name__ == "__main__":
    base_dir = os.path.dirname(os.path.abspath(__file__))
    default_csv = os.path.join(base_dir, "benchmark_results.csv")
    csv_file = sys.argv[1] if len(sys.argv) > 1 else default_csv
    analyze_results(csv_file)