Skip to content

Conversation

@Manamama-Gemini-Cloud-AI-01

This Pull Request enhances the python/scripts/bench.py script by adding a proper command-line interface (CLI) and a default benchmark execution flow.

Background:
Previously, python/scripts/bench.py was designed as a Python module, lacking a if __name__ == "__main__": block for direct execution. This led to a confusing user experience where running the script directly (or with --help) produced no output or executed no benchmark, despite the README.md implying its usability.

Key Changes:

  1. Added if __name__ == "__main__": block: The script now includes a standard entry point for direct execution.
  2. Integrated argparse: A command-line parser has been added, enabling:
    • python bench.py --help: Displays usage instructions, including options for running benchmarks.
    • python bench.py --run: Executes a quick default benchmark with configurable count, ndim, and connectivity.
    • python bench.py --test_core: Runs a basic functionality test for usearch (Index creation, add, search).
  3. Default Benchmark Execution: The --run option now executes a default benchmark using bench_params.
    • Ground truth generation is implemented using usearch.index.search(exact=True) to avoid external dependencies like scikit-learn.
    • The Evaluation object is correctly configured with AddTask and SearchTask to produce numerical results for add_per_second, search_per_second, and recall_at_one.

Benefits:

  • Improved Usability: Users can now run bench.py directly from the command line to quickly test usearch functionality and get benchmark figures without writing wrapper scripts.
  • Aligned with Documentation: The script's behavior now better aligns with the implicit expectations set by README.md and BENCHMARKS.md.
  • Self-Contained Testing: The benchmark now uses usearch's own capabilities for ground truth generation, making it more robust and reducing external dependencies for basic benchmarking.

This PR makes bench.py a more functional and user-friendly tool for quick local testing and performance verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant