Vector and Carray's efficiency difference is too big.
For both, I have not made other special settings, that is, declare variables and start use. I don't know how they allocate memory, but I know the efficiency difference between them.
There are about 38,000 pieces of data from the database, written in two ways: Vector and Carray
Use Push_Back, Carray uses add. Carray used it about 15 minutes, and Vector only 35 seconds. This gap is today's first truly experience.
For the first time, I will refer to it later.
Carray
Vector
2020.3.9 Supplement: This is probably 2 or 3 years ago, so only explains the situation, the specific number is just a problem, not the actual data. I have written a file analysis tool very early (about 2006) (I have been using today, from the beginning to the maintenance update), add a record to a vector, using push_back (). Under normal circumstances, the file will not be too large, the maximum will exceed 1GB, the number of records generated is usually within 10W, and there is more than 10 W. This tool is in the process of use, sometimes some abnormal files, the maximum of 20 GB, and the analysis process is very slow. Later, in order to find slow problems, I followed the VECTOR variable that recorded the distribution. The speed of each push_back () was found, and I found a problem that had not been seriously treated by the past, that is, when I started, this push_back () speed is very fast. , But when the record reaches 20 W, especially after 50 W, the speed is very slow, after more than 100 w, it will wait for a long time, and then modify it, each 10W is divided into one group In a vector, when there is a lot of records in a file, there will be multiple vectors to store, so after modification, the speed is much faster. As you can see here, if just simply push_back (), that a vector does not have too much content as much as possible.