[Enchancement] Benchmarking for Coin Selection Algorithms #57
+1,092
−0
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.
Benchmarking Coin Selection Algorithms
This pull request introduces benchmarks for six coin selection algorithms in the
rust-coinselect
library using thecriterion
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 usingcargo bench
in the terminal.Algorithms Benchmarked
BNB (Branch and Bound): Efficiently solves combinatorial optimization problems by exploring possible solutions and pruning suboptimal branches.
FIFO (First In, First Out): Selects coins based on their order of arrival, providing a straightforward selection method.
Knapsack: Aims to maximize the value of selected coins while adhering to a weight limit, mimicking the classic knapsack problem.
Lowest Larger: Chooses the smallest available coin larger than the target amount; defaults to another strategy if none exist.
SRD (Single Random Draw): Randomly selects a coin from available inputs, useful for testing distribution.
select_coin
Function: A high-level interface that wraps the above algorithms, allowing for unified performance evaluation.Importance of Benchmarking
Benchmarking is vital for:
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.