feat(python): Enhance bench.py with CLI and default benchmark execution #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request enhances the
python/scripts/bench.pyscript by adding a proper command-line interface (CLI) and a default benchmark execution flow.Background:
Previously,
python/scripts/bench.pywas designed as a Python module, lacking aif __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 theREADME.mdimplying its usability.Key Changes:
if __name__ == "__main__":block: The script now includes a standard entry point for direct execution.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 configurablecount,ndim, andconnectivity.python bench.py --test_core: Runs a basic functionality test forusearch(Index creation, add, search).--runoption now executes a default benchmark usingbench_params.usearch.index.search(exact=True)to avoid external dependencies likescikit-learn.Evaluationobject is correctly configured withAddTaskandSearchTaskto produce numerical results foradd_per_second,search_per_second, andrecall_at_one.Benefits:
bench.pydirectly from the command line to quickly testusearchfunctionality and get benchmark figures without writing wrapper scripts.README.mdandBENCHMARKS.md.usearch's own capabilities for ground truth generation, making it more robust and reducing external dependencies for basic benchmarking.This PR makes
bench.pya more functional and user-friendly tool for quick local testing and performance verification.