Home » Developing U++ » U++ Developers corner » Impressive improvement in stl::vector when dealing with raw memory.
Re: Impressive improvement in stl::vector when dealing with raw memory. [message #59173 is a reply to message #59169] |
Mon, 14 November 2022 09:46   |
pvictor
Messages: 75 Registered: December 2015
|
Member |
|
|
Hi!
Here's my results:
TIMING Upp::Vector<int>::insert: 478.83 s - 15.96 s (478.83 s / 30 ), min: 15.82 s , max: 16.10 s , nesting: 0 - 30
TIMING std::vector<int>::insert: 478.96 s - 15.97 s (478.96 s / 30 ), min: 15.82 s , max: 16.09 s , nesting: 0 - 30
TIMING Upp::Vector<int>::push_back: 30.00 ms - 999.97 us (30.00 ms / 30 ), min: 1.00 ms, max: 1.00 ms, nesting: 0 - 30
TIMING std::vector<int>::push_back: 32.00 ms - 1.07 ms (32.00 ms / 30 ), min: 1.00 ms, max: 2.00 ms, nesting: 0 - 30
TIMING Upp::Vector<Buff>::push_back: 2.34 s - 78.10 ms ( 2.34 s / 30 ), min: 76.00 ms, max: 82.00 ms, nesting: 0 - 30
TIMING std::vector<Buff>::push_back: 1.79 s - 59.70 ms ( 1.79 s / 30 ), min: 58.00 ms, max: 68.00 ms, nesting: 0 - 30
However, when I modify the code:
void TestCharBuffer() {
for(int i=0; i < M; ++i) {
{
RTIMING("std::vector<Buff>::push_back");
std::vector<Buff> v;
v.reserve(N); // +++
for(int i = 0; i < N; i++) {
Buff b;
v.push_back(b);
}
}
{
RTIMING("Upp::Vector<Buff>::push_back");
Upp::Vector<Buff> v;
v.Reserve(N); // +++
for(int i = 0; i < N; i++){
Buff b;
v.Add(b);
}
}
}
}
I get:
TIMING Upp::Vector<Buff>::push_back: 834.00 ms - 27.80 ms (834.00 ms / 30 ), min: 27.00 ms, max: 29.00 ms, nesting: 0 - 30
TIMING std::vector<Buff>::push_back: 834.00 ms - 27.80 ms (834.00 ms / 30 ), min: 27.00 ms, max: 30.00 ms, nesting: 0 - 30
It seems that Upp::Vector wastes more time for memory allocation.
Best regards,
Victor
|
|
|
 |
|
Impressive improvement in stl::vector when dealing with raw memory.
By: Lance on Mon, 14 November 2022 01:48
|
 |
|
Re: Impressive improvement in stl::vector when dealing with raw memory.
By: pvictor on Mon, 14 November 2022 09:46
|
 |
|
Re: Impressive improvement in stl::vector when dealing with raw memory.
By: Lance on Mon, 14 November 2022 14:31
|
 |
|
Re: Impressive improvement in stl::vector when dealing with raw memory.
By: Lance on Mon, 14 November 2022 14:52
|
 |
|
Re: Impressive improvement in stl::vector when dealing with raw memory.
By: Lance on Mon, 14 November 2022 15:28
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: Lance on Mon, 14 November 2022 17:24
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: Lance on Tue, 15 November 2022 15:58
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: Lance on Sat, 19 November 2022 22:04
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: Lance on Sun, 20 November 2022 01:50
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: mirek on Mon, 21 November 2022 16:34
|
 |
|
Re: Impressive improvement in std::vector when dealing with raw memory.
By: Lance on Wed, 23 November 2022 00:39
|
Goto Forum:
Current Time: Sat Jun 07 16:52:34 CEST 2025
Total time taken to generate the page: 0.04914 seconds
|