Bitshala-Incubator / rust-coinselect

A blockchain-agnostic coinselection library built in rust.
MIT License
9 stars 17 forks source link

[Enchancement] Benchmarking for Coin Selection Algorithms #55

Open NeoZ666 opened 1 month ago

NeoZ666 commented 1 month ago

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.

Algorithms to be 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:

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.

NeoZ666 commented 1 month ago

57