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

Improve SliceExt::binary_search performance #45333

Merged
merged 1 commit into from
Nov 11, 2017
Merged

Improve SliceExt::binary_search performance #45333

merged 1 commit into from
Nov 11, 2017

Commits on Nov 11, 2017

  1. Improve the performance of binary_search by reducing the number of

    unpredictable conditional branches in the loop. In addition improve the
    benchmarks to test performance in l1, l2 and l3 caches on sorted arrays
    with or without dups.
    
    Before:
    
    ```
    test slice::binary_search_l1                               ... bench:  48 ns/iter (+/- 1)
    test slice::binary_search_l2                               ... bench:  63 ns/iter (+/- 0)
    test slice::binary_search_l3                               ... bench: 152 ns/iter (+/- 12)
    test slice::binary_search_l1_with_dups                     ... bench:  36 ns/iter (+/- 0)
    test slice::binary_search_l2_with_dups                     ... bench:  64 ns/iter (+/- 1)
    test slice::binary_search_l3_with_dups                     ... bench: 153 ns/iter (+/- 6)
    ```
    
    After:
    
    ```
    test slice::binary_search_l1                               ... bench:  15 ns/iter (+/- 0)
    test slice::binary_search_l2                               ... bench:  23 ns/iter (+/- 0)
    test slice::binary_search_l3                               ... bench: 100 ns/iter (+/- 17)
    test slice::binary_search_l1_with_dups                     ... bench:  15 ns/iter (+/- 0)
    test slice::binary_search_l2_with_dups                     ... bench:  23 ns/iter (+/- 0)
    test slice::binary_search_l3_with_dups                     ... bench:  98 ns/iter (+/- 14)
    ```
    Alkis Evlogimenos authored and alkis committed Nov 11, 2017
    Configuration menu
    Copy the full SHA
    2ca111b View commit details
    Browse the repository at this point in the history