Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enchancement] Benchmarking for Coin Selection Algorithms #57

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NeoZ666
Copy link
Contributor

@NeoZ666 NeoZ666 commented Oct 6, 2024

Benchmarking Coin Selection Algorithms

This pull request introduces benchmarks for six coin selection algorithms in the rust-coinselect library using the criterion crate. These benchmarks will help assess and optimize performance across different strategies.

What's Criterion ?

Criterion is a powerful benchmarking library for Rust that allows developers to measure and analyze the performance of their code with precision. It provides detailed reports, statistical analysis, and features like automatic benchmarking for different configurations, making it easy to identify performance bottlenecks.

To find the reports, navigate to rust-coinselect/target/criterion/report/index.html after using cargo bench in the terminal.

Algorithms Benchmarked

  1. BNB (Branch and Bound): Efficiently solves combinatorial optimization problems by exploring possible solutions and pruning suboptimal branches.

  2. FIFO (First In, First Out): Selects coins based on their order of arrival, providing a straightforward selection method.

  3. Knapsack: Aims to maximize the value of selected coins while adhering to a weight limit, mimicking the classic knapsack problem.

  4. Lowest Larger: Chooses the smallest available coin larger than the target amount; defaults to another strategy if none exist.

  5. SRD (Single Random Draw): Randomly selects a coin from available inputs, useful for testing distribution.

  6. select_coin Function: A high-level interface that wraps the above algorithms, allowing for unified performance evaluation.

Importance of Benchmarking

Benchmarking is vital for:

  • Performance Optimization: Identifying and addressing bottlenecks.
  • Algorithm Comparison: Evaluating efficiency under various conditions.
  • Regression Detection: Monitoring for performance changes with new updates.
  • Resource Management: Efficiently utilizing CPU and memory.
  • Enhanced User Experience: Ensuring responsive application performance.

This addition ensures that we can effectively measure and optimize the performance of our coin selection algorithms, maintaining high efficiency for the rust-coinselect library.

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