Comments (2)
Ok, it's my fault. I'm not noticed that you have a Table& operator=(Table&& o)
method, sorry~
I've only seen the Table& operator=(Table const& o)
one what is immediately above the swap
method :-)
from robin-hood-hashing.
Hi @asbai, the swap already is O(1). I took your issue as an opportunity to demonstrate this with nanobench. I've added a benchmark that calculates complexity of swap:
robin-hood-hashing/src/test/unit/bench_swap.cpp
Lines 18 to 27 in f577ca9
This benchmarks swap() with differently sized maps. It can be clearly seen that swap performance is always constant at 11.27 ns/op:
complexityN | ns/op | op/s | err% | ins/op | cyc/op | IPC | total | benchmark |
---|---|---|---|---|---|---|---|---|
10 | 11.27 | 88,736,885.89 | 0.0% | 63.01 | 35.98 | 1.751 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
30 | 11.27 | 88,728,648.87 | 0.0% | 63.01 | 36.01 | 1.750 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
70 | 11.28 | 88,658,752.21 | 0.1% | 63.01 | 36.02 | 1.749 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
150 | 11.29 | 88,580,392.83 | 0.1% | 63.01 | 36.06 | 1.747 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
310 | 11.29 | 88,578,516.95 | 0.1% | 63.01 | 36.05 | 1.748 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
630 | 11.27 | 88,723,132.79 | 0.0% | 63.01 | 36.00 | 1.750 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
1,270 | 11.27 | 88,731,841.38 | 0.0% | 63.01 | 36.00 | 1.750 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
2,550 | 11.27 | 88,734,786.30 | 0.0% | 63.01 | 36.01 | 1.750 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
5,110 | 11.27 | 88,736,885.89 | 0.0% | 63.01 | 35.99 | 1.751 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
10,230 | 11.27 | 88,735,566.10 | 0.0% | 63.01 | 35.99 | 1.751 | 0.00 | swap <robin_hood::unordered_flat_map<uint64_t, uint64_t>> |
Additionally, this data can be used to fit different complexity curves to the data. Unsurprisingly, the best fitting curve with an error of only 0.1% is O(1)
:
coefficient | err% | complexity |
---|---|---|
1.12747e-08 | 0.1% | O(1) |
1.15522e-09 | 33.8% | O(log n) |
1.64601e-12 | 83.8% | O(n) |
1.20108e-13 | 85.6% | O(n log n) |
1.34512e-16 | 91.3% | O(n^2) |
1.18374e-20 | 93.4% | O(n^3) |
So no need to worry, swap already is O(1).
from robin-hood-hashing.
Related Issues (20)
- Segmentation fault: 11 with std::this_thread::get_id(); as key in C++ HOT 5
- Idea for robin-hood-hashing V2 HOT 1
- Keys are not marked as const when used structured binding during iteration over container HOT 2
- My problem with robin_hood::erase HOT 4
- robin_hoodConfig.cmake missing HOT 4
- terminate called after throwing an instance of 'std::overflow_error' what(): robin_hood::map overflow Aborted (core dumped) HOT 5
- hope to support bazel HOT 1
- How can I further improve performance in a read-only load? HOT 2
- func unaligned_load can be optimized HOT 2
- Please only build tests when BUILD_TESTING=ON HOT 1
- undefined symbol: std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) HOT 1
- Project doesn't install anything HOT 1
- Possible Data Corruption Bug? HOT 2
- Potentially critical bug in Robin Hood invariant checking HOT 4
- does insert support std::pair? HOT 1
- Consider using `INTERFACE_SYSTEM_INCLUDE_DIRECTORIES`
- Explicit template instantiation
- There is a coredump if I defined <std::string, std::shared_ptr<void>> when a pointer delete
- intel compiler warnings (not a bug)
- crash because alignment of key is not respected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robin-hood-hashing.