I always wanted to know which efficiency is higher for vector and list in std. Therefore, a simple test was conducted to compare the efficiency of the push_back and traversal operations of std vector and list. Result 1: 1. push_back operation: 100000 elements are operated continuously by push_back, and then clear (). It has been repeated for 10000 times. The vector takes 13 s, and the list takes 118 s. 2. traversal operation: The iterator is used to traverse the vector and list of 100000 elements, traversing 10000 times. Vector takes 20 s, and list takes 15 s. If an ordered element is added, the efficiency of vector is nearly 10 times higher than that of list, when an iterator is used to traverse elements, the efficiency is not much different. Code: [cpp] # include <iostream> # include <vector> # include <list> # include <ctime> using namespace std; class Message {}; int main () {vector <Message *> vt; list <Message *> lt; Message * msg = new Message (); time_t start = time (NULL); for (int I = 0; I <10000; ++ I) {vt. clear (); for (int j = 0; j <100000; ++ j) {vt. push_back (msg) ;}} time_t end = time (NULL); cout <"vector spend time" <end-s Tart <endl; start = time (NULL); for (int I = 0; I <10000; ++ I) {lt. clear (); for (int j = 0; j <100000; ++ j) {lt. push_back (msg) ;}}end = time (NULL); cout <"list spend time" <end-start <endl; delete msg; msg = NULL; start = time (NULL); for (int I = 0; I <10000; ++ I) {typeof (vt. begin () it = vt. begin (); while (it! = Vt. end () {msg = * it; ++ it;} end = time (NULL); cout <"vector spend time" <end-start <endl; start = time (NULL); for (int I = 0; I <10000; ++ I) {typeof (lt. begin () it = lt. begin (); while (it! = Lt. end () {msg = * it; ++ it;} end = time (NULL); cout <"list spend time" <end-start <endl; return 0;} output: vector spend time 13 list spend time 118 vector spend time 20 list spend time 15