Skip to content

auto: rm std::map::StdMap trait, rename std::map to std::oldmap and start transition to the core::container::Map API #4746

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

Merged
merged 13 commits into from
Feb 4, 2013

Conversation

thestinger
Copy link
Contributor

The rationale for renaming is that there isn't any reason to prefer std::map (not sendable, legacy API, and slower) over core::hashmap::linear, and it makes it obvious that the module in core is the one to use. Migrating to core::hashmap will take a fair bit of a work, but in most cases it should be as simple as marking the variable as mutable and replacing a few copies with borrowed pointers.

Any future hash table implementations will implement the core::container::Map trait so migrating between them will be simple. My plan is to incrementally turn the old map into an owned core::hashmap::chained container. It may or not be a useful container worth keeping around, but it's too hard to migrate right to LinearMap everywhere at once.

Here are the current benchmarks:

% ./core-map 1000
std::map::HashMap
               sequential_ints 0.001247 s
                   random_ints 0.001063 s
                   delete_ints 0.000392 s
            sequential_strings 0.002818 s
                random_strings 0.00088 s
                delete_strings 0.000348 s
core::hashmap::linear::LinearMap
               sequential_ints 0.000416 s
                   random_ints 0.000365 s
                   delete_ints 0.000139 s
            sequential_strings 0.000822 s
                random_strings 0.00059 s
                delete_strings 0.000329 s

% ./core-map 10000
std::map::HashMap
               sequential_ints 0.009247 s
                   random_ints 0.00382 s
                   delete_ints 0.001583 s
            sequential_strings 0.014042 s
                random_strings 0.008566 s
                delete_strings 0.00445 s
core::hashmap::linear::LinearMap
               sequential_ints 0.004112 s
                   random_ints 0.003433 s
                   delete_ints 0.001645 s
            sequential_strings 0.008921 s
                random_strings 0.006459 s
                delete_strings 0.004639 s

% ./core-map 100000
std::map::HashMap
               sequential_ints 0.092820 s
                   random_ints 0.076495 s
                   delete_ints 0.027946 s
            sequential_strings 0.171406 s
                random_strings 0.118372 s
                delete_strings 0.055188 s
core::hashmap::linear::LinearMap
               sequential_ints 0.062137 s
                   random_ints 0.050849 s
                   delete_ints 0.018603 s
            sequential_strings 0.119988 s
                random_strings 0.071857 s
                delete_strings 0.047536 s

% ./core-map 1000000
std::map::HashMap
               sequential_ints 0.877039 s
                   random_ints 0.890236 s
                   delete_ints 0.278055 s
            sequential_strings 1.756422 s
                random_strings 1.576072 s
                delete_strings 0.595255 s
core::hashmap::linear::LinearMap
               sequential_ints 0.643638 s
                   random_ints 0.503949 s
                   delete_ints 0.226117 s
            sequential_strings 1.185846 s
                random_strings 0.739722 s
                delete_strings 0.528093 s

@brson brson merged commit 4fd9264 into rust-lang:incoming Feb 4, 2013
@brson
Copy link
Contributor

brson commented Feb 4, 2013

Thanks

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