Run Code  | API  | Code Wall  | Users  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

stl_sizeof.cc

Language: Layout:
+ ] Compiler args + ] Show input
Compilation time: 1.43 sec, absolute running time: 1.26 sec, cpu time: 1.75 sec, memory peak: 208 Mb, absolute service time: 2,7 sec 
edit mode |  history  | discussion
Displaying memory usage in bytes.
Filling data structures with 1000000 elements and reporting the per element memory usage.
memory usage per element of a vector<uint32_t> : 4.1943
memory usage per element of a list<uint32_t> : 24
memory usage per element of a deque<uint32_t> : 4.16408
memory usage per element of an unordered_set<uint32_t> : 24.4506
memory usage per element of a set<uint32_t> : 40
memory usage per element of a unordered_map<uint32_t, uint32_t> : 24.4506
memory usage per element of a map<uint32_t, uint32_t> : 40
Comments : 
This is an optimistic estimate: the overhead of the data structure and the allocations is ignored.
Because the per-value overhead might be fixed, the results might be less dramatic with larger elements, such as long strings.