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 » Value size ?
Value size ? [message #42904] Sun, 13 April 2014 23:43 Go to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
I saw in several places talking about efficiency but when I look at sizeof(Value) == 48 (64bits) I'm not sure about it.

I saw that Value has a String member called "data" and also an Atomic member called "refcount" to be used in special cases, but String also has the same "refcount" for special cases, isn't it a repetition ?

I was looking at sizeof(boost::any) == 8 (64bits) and sizeof(cdiggins::any) == 16 (64bits) ( http://www.codeproject.com/Articles/11250/High-Performance-D ynamic-Typing-in-C-using-a-Repla) and wondering why we need so much memory for Value ?

It's used on collections and this size adds to the end, also I saw on database examples using ValueMap inside ValueArray.
Why construct individual maps with lots of duplicated string keys ?
Wouldn't be more efficient to have only one set of keys and an Vector<ArrayValue> let's call it ValueTable ?

Renderer& Renderer::operator()(const char *id, const SqlSelect& sel)
{
	ValueArray list;
	ValueMap vm;
	SqlR sql;
	sql * sel;
	while(sql.Fetch(vm))
		list.Add(vm);
	return operator()(id, list);
}
Re: Value size ? [message #42907 is a reply to message #42904] Mon, 14 April 2014 06:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mingodad wrote on Sun, 13 April 2014 21:43
I saw in several places talking about efficiency but when I look at sizeof(Value) == 48 (64bits) I'm not sure about it.


sizeof(Value) is 16 bytes. I guess you have tried in DEBUG, where there is some additional diagnostics data.

Quote:

I saw that Value has a String member called "data" and also an Atomic member called "refcount" to be used in special cases, but String also has the same "refcount" for special cases, isn't it a repetition ?


Not at all.

Quote:

I was looking at sizeof(boost::any) == 8 (64bits) and sizeof(cdiggins::any) == 16 (64bits)


How much _total_ memory would boost::any consume if you assign it an int or "Hello world"?

Value will still use 16 bytes _total_ in both cases.

BTW, to investigate such issues further, there is benchamarks/sizeof which I use to track this. Also funny is benchamrks/idmapBench, which benchmarks (among others) ValueMap against STL (that is, high-level U++ thing against low-level STL thing).

Mirek
Re: Value size ? [message #42909 is a reply to message #42907] Mon, 14 April 2014 10:00 Go to previous message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
Thanks again for the explanation !

Yes you are right I was measuring then in debug mode and otherwise it's sizeof(Value) == 16 (64bits).

And yes the "refcount" is in an internal class declaration only, the String "data" member is the real storage.

Thanks again for your time, attention and great work !

[Updated on: Mon, 14 April 2014 10:03]

Report message to a moderator

Previous Topic: How is the u++ repository organized ?
Next Topic: Pop3 class and reference examples for U++
Goto Forum:
  


Current Time: Fri Mar 29 09:29:25 CET 2024

Total time taken to generate the page: 0.01892 seconds