Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
pvictor is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: WebSocket client SSL support?
Next Topic: theide with libclang
Goto Forum:
  


Current Time: Sat Jun 07 16:52:34 CEST 2025

Total time taken to generate the page: 0.04914 seconds