All the results are shown in second.
num | push_back | resize | reserve | emplace_back | reserve alt | resize alt |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 |
2000000 | 1.39 | 0.422 | 0.984 | 1.312 | 0.953 | 0.406 |
4000000 | 2.813 | 0.843 | 1.985 | 2.734 | 1.906 | 0.797 |
6000000 | 4.188 | 1.281 | 2.969 | 4.094 | 2.859 | 1.187 |
8000000 | 5.797 | 1.703 | 3.969 | 5.687 | 3.844 | 1.61 |
10000000 | 6.797 | 2.125 | 4.969 | 6.625 | 4.766 | 1.985 |
num | push_back | resize | reserve | emplace_back | reserve alt | resize alt |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 |
2000000 | 0.047 | 0.016 | 0.015 | 0.031 | 0.016 | 0.016 |
4000000 | 0.093 | 0.047 | 0.031 | 0.063 | 0.031 | 0.015 |
6000000 | 0.125 | 0.047 | 0.046 | 0.11 | 0.016 | 0.031 |
8000000 | 0.187 | 0.079 | 0.062 | 0.156 | 0.031 | 0.032 |
10000000 | 0.188 | 0.079 | 0.078 | 0.172 | 0.047 | 0.047 |
num | push_back | resize | reserve | emplace_back | reserve alt | push back alt | push back alt move |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1000000 | 1.063 | 0.594 | 0.687 | 0.969 | 0.625 | 1.234 | 1.078 |
2000000 | 2.157 | 1.156 | 1.391 | 2.047 | 1.25 | 2.562 | 2.25 |
3000000 | 3.266 | 1.735 | 2.047 | 3.063 | 1.86 | 3.828 | 3.375 |
4000000 | 4.562 | 2.297 | 2.735 | 4.282 | 2.485 | 5.312 | 4.703 |
5000000 | 5.234 | 2.906 | 3.422 | 4.875 | 3.094 | 6.172 | 5.422 |
num | push_back | resize | reserve | emplace_back | reserve alt | push back alt | push back alt move |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1000000 | 0.094 | 0.109 | 0.062 | 0.078 | 0.063 | 0.14 | 0.094 |
2000000 | 0.187 | 0.235 | 0.14 | 0.172 | 0.125 | 0.266 | 0.187 |
3000000 | 0.266 | 0.328 | 0.187 | 0.266 | 0.203 | 0.407 | 0.282 |
4000000 | 0.391 | 0.453 | 0.266 | 0.375 | 0.266 | 0.563 | 0.375 |
5000000 | 0.453 | 0.594 | 0.313 | 0.453 | 0.297 | 0.64 | 0.406 |
Benchmark A
Debug
push_back
Release
reserve_alt
resize_alt
がコンストラクタ呼ばれる回数最小なので、最速になるBenchmark B
Debug
move
セマンティクスを使えないpush back alt
が圧倒的に遅いreserve
よりreserve_alt
が速い →emplace_back
の効果が見えるRelease
resize
が遅くなる?