Does XCODE .... or is there any way to force or verify this

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Does XCODE .... or is there any way to force or verify t

Post by gravy »

His code is about initialisers.

New generally usually uses malloc which is understandably dog slow.

C++ gives you -loads- of ways to do your own memory allocation if speed is an issue.
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Does XCODE .... or is there any way to force or verify t

Post by Dio »

tufty wrote:With -Os, we get this:

Code: Select all

	movl	$0, (%eax)
	movl	$0, 4(%eax)
	movl	$0, 8(%eax)
You aren't gonna get much faster than that.
Bit of a piddly small class though - the examples I'm talking about are generally in the 400-1K bytes region (hence also why stack allocation isn't a concern). For a region that size, even rep movsd or similar is about two thirds the performance of SSE memset and a load of straight-line immediate moves would be well under half as well as trashing the icache.

If you test a few non-trivial cases, you'll see that generally compilers are pretty awful at this stuff, even MSVC (which, in my experience, is a bit better than gcc, albeit that I haven't looked at gcc object code for a few years).

Initialisation of such large classes can take much longer than the malloc. I've plenty of data to prove that :) .
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Does XCODE .... or is there any way to force or verify t

Post by gravy »

Are you generating code or something?

If initialising vars is taking longer than the malloc you must have hundreds of vars.

You got an example of what you're doing because I just can't see it unless you've some monolithic class with a ludicrous amount of member vars.
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Does XCODE .... or is there any way to force or verify t

Post by Dio »

Yes, hundreds of member vars.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Does XCODE .... or is there any way to force or verify t

Post by gilesgoat »

3 days and a half I found another "exoterism" I won't even write .. well in short it's only one line of code missing that should set a var to a value in case a flag is set changing a colour.

The line is missing so that coulour never changes, as in fact it should .. on the PC it stays exactly the same because it's never touched.

But someway on the iPad it does .. and I tried various things I'd dare to say ( cause there are other things in the same loop where that colour IS changed and they are all together processed the same identical way and if I change/touch it I can see it changing ) 'the only way it can happen you HAVE to change that value'.

This is really bizzarre ...
Giles the billy goat
"Baa"
Post Reply