std::vector, list, deque의 벤치마크
2018. 3. 5. 00:28
https://baptiste-wicht.com/posts/2012/12/cpp-benchmark-vector-list-deque.html
To conclude, we can get some facts about each data structure:
- std::list is very very slow to iterate through the collection due to its very poor spatial locality.
- std::vector and std::deque perform always faster than std::list with very small data
- std::list handles very well large elements
- std::deque performs better than a std::vector for inserting at random positions (especially at the front, which is constant time)
- std::deque and std::vector do not support very well data types with high cost of copy/assignment
This draw simple conclusions on usage of each data structure:
- Number crunching: use std::vector or std::deque
- Linear search: use std::vector or std::deque
- Random Insert/Remove:
- Small data size: use std::vector
- Large element size: use std::list (unless if intended principally for searching)
- Non-trivial data type: use std::list unless you need the container especially for searching. But for multiple modifications of the container, it will be very slow.
- Push to front: use std::deque or std::list
일단은 참고
'프로그래밍 > C, C++ 공부' 카테고리의 다른 글
C++ 11 (0) | 2018.03.11 |
---|---|
STL 컨테이너 선택 알고리즘 (0) | 2018.03.11 |
free,와 delete[]는 배열의 크기를 어떻게 아는걸까? (0) | 2018.03.02 |
str 시리즈 구현해보기 (strlen, strcpy, strncpy, strcat, strcmp, strchr, strstr, strtok) (0) | 2018.02.26 |
왜 strchr의 두번째 인자는 char가 아닌 int일까? (0) | 2018.02.25 |