Skip to content

Conversation

jruderman
Copy link
Contributor

No description provided.

@brson
Copy link
Contributor

brson commented Jul 28, 2011

Integrated.

@brson brson closed this Jul 28, 2011
keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this pull request Dec 12, 2017
pdietl pushed a commit to pdietl/rust that referenced this pull request Apr 23, 2020
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this pull request Mar 7, 2023
* Enable custom allocation

* Fix llvm7

* Fix 14

Co-authored-by: William Moses <[email protected]>
celinval pushed a commit to celinval/rust-dev that referenced this pull request Jun 4, 2024
noscripter pushed a commit to noscripter/rust that referenced this pull request Sep 8, 2025
* perf: Optimize BTree search using binary search

This commit optimizes the search function in the BTree implementation
by replacing the linear search with a binary search algorithm. This
change significantly improves the search performance, especially for
large trees.

Implementation details:
- Modified the `search` method in the `BTree` struct
- Replaced the while loop with `binary_search` method on the `keys` vector

Complexity analysis:
- Previous implementation: O(n) per node, where n is the number of keys
- New implementation: O(log n) per node

Benchmark results:
- Environment: MacOS 14.5, Apple M1 Pro, 32 GB RAM
- Dataset: 1,000,000 random integers for insertion
- Search: 1,000,000 searches for the key 500,000
- Before:
  - Insertion: 3.002587333s
  - Search: 2.334683584s
- After:
  - Insertion: 2.998482583s
  - Search: 288.659458ms

Note: Insertion time remains largely unchanged, as expected. All
existing tests pass with the new implementation.

Benchmark code is not included in this commit.

* tests: expand existing `test_search`

---------

Co-authored-by: Piotr Idzik <[email protected]>
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.

2 participants