Testing some myVector functions against std::vector functions. Testing with these elements in containers: 1, 2, 3
In the table, results are taken after calling the function.
Container\Function | emplace_back(4) | resize(2) | erase(T.begin()+1) | insert(T.begin(), 5) | reserve(999) |
---|---|---|---|---|---|
std::vector | elements: 1, 2, 3, 4 | size: 2 | elements: 1, 3 | elements: 5, 1, 2, 3 | capacity: 999 |
myVector | elements: 1, 2, 3, 4 | size: 2 | elements: 1, 3 | elements: 5, 1, 2, 3 | capacity: 999 |
Testing how much time it takes to fill a container with integers:
Container\Size | 10k | 100k | 1M | 10M | 100M |
---|---|---|---|---|---|
std::vector | 5.4e-05s | 0.000475s | 0.002321s | 0.030825s | 0.278785s |
myVector | 3.9e-05s | 0.000412s | 0.00208s | 0.026683s | 0.214362s |
TIME IMPROVEMENT | 27.78% | 13.26% | 10.39% | 13.43% | 23.11% |
The number of memory reallocations for both the myVector and std::vector containers, when filling them with 100,000,000 elements, is 27.