Timeline for Inserting and fetching values slower on an unordered_map in C++ than on a dictionary in Python
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 3, 2017 at 15:56 | answer | added | Edward | timeline score: 11 | |
Dec 3, 2017 at 8:26 | history | edited | Jamal | CC BY-SA 3.0 |
edited body; edited tags
|
Nov 30, 2017 at 17:33 | comment | added | Loki Astari |
bool isin(long s, unordered_map<long,long> m) . Here you are making a copy of the map each time you call isin !!!!
|
|
Nov 29, 2017 at 7:48 | answer | added | einpoklum | timeline score: -1 | |
Nov 29, 2017 at 5:07 | answer | added | user128454 | timeline score: 13 | |
Nov 28, 2017 at 23:02 | review | Close votes | |||
Nov 29, 2017 at 8:59 | |||||
Nov 28, 2017 at 23:01 | history | edited | Jamal | CC BY-SA 3.0 |
deleted 45 characters in body; edited title
|
Nov 28, 2017 at 22:14 | comment | added | WNG | @Frank yeah, it kinda makes sense now, so passing the variable as a reference in my function definition (or stopping refering to this function that does really make my program shorter or clearer) did it for me (well at least until my next problem which seems to be an extremely fast (thanks to you) integer overflow :) ) | |
Nov 28, 2017 at 22:11 | comment | added | Incomputable | @Frank, sadness. I expected clang to be able to elide this. I believe it is possible to run optimization passes multiple times. I'll play with some cv qualifiers. It seems like clang doesn't expose optimization pipeline. I've seen Mr. Carruth performing it on cppcon. | |
Nov 28, 2017 at 22:09 | comment | added | user128454 | @Incomputable, yep: no heap elision: see on godbolt see the call to the copy constructor on line #176 | |
Nov 28, 2017 at 22:06 | comment | added | user128454 |
@Incomputable that would require heap elision to be able to be performed in that scenario, since new and delete qualify as side effects normally. Since heap elision is so new and unordered_map is so complex, I'd be surprised if it happened in that scenario. (I'll still check out of curiosity)
|
|
Nov 28, 2017 at 21:59 | comment | added | Incomputable | @Frank, recently I stumbled upon bad page aligning. Performance hit was 50x, so now I am more hesitant about guessing :) I believe static analysis should be able to prove non-mutability, since the logic of find is not that complicated. Cannot reach godbolt right now, I will test it tomorrow. | |
Nov 28, 2017 at 21:58 | history | edited | Sᴀᴍ Onᴇᴌᴀ♦ | CC BY-SA 3.0 |
update formatting, fix spelling
|
Nov 28, 2017 at 21:57 | comment | added | user128454 |
your isin() function makes a copy of the unordered_set every single time it's called.
|
|
Nov 28, 2017 at 21:57 | comment | added | Incomputable | “Implementation of find is incredibly slower in unordered map”? Wut? Try to run perf if you’re on linux, it will give you all the metrics you need. If you would know standard algorithms, you wouldn’t need most of those macros. | |
Nov 28, 2017 at 21:48 | review | First posts | |||
Nov 28, 2017 at 21:48 | |||||
Nov 28, 2017 at 21:46 | history | asked | WNG | CC BY-SA 3.0 |