[TYPO3-core] RFC Feature #16189: Optimize stdWrap usage for TypoScript content element CLEARGIF

JoH asenau info at cybercraft.de
Mon Nov 1 09:27:17 CET 2010


> Results:
> sprintf takes 5.63 _micro_seconds per call on my machine
> string concatenation takes 2.94 _micro_seconds per call
> 
> So, isn't it worth to additionally spend 2,96 _micro_seconds for a
> much more readable code?

Frankly said: No!
Reason: It's not about just these 2,69 microseconds but about the aggregated microseconds of each and every sprintf call, which might quickly add up to some milliseconds.

From my POV performance should never be sacrificed just for the readability of the code, which is one of the major drawbacks I see in the upcoming coding style of FLOW3 and the like. So my rule of thumb would be:
Check, which of the functions is faster and make the "winning" function as readable as possible.

> (Just for comparison: Save a single database request somewhere else
> and you easily save _1000x_ more time...)

Of course, but IMHO this doesn't justify wasting time in other places as well.
 
> I use sprintf also for exception messages and other places where I
> have 
> to insert dynamic content into a static string. It is somehow like a
> little "templating engine" and it gives you the possibility to easily
> search for that string in the code. Additionally you can see at first
> sight how the resulting string will look like and can check if all
> brackets and quotes are in place.
> 
> Maybe this is peanuts for this patch, but I would really like to see
> this in other parts of the core as-well...

I don't - but it's not my decision, since I am neither a core developer nor the release manager.

But maybe you take a look at the version I attached, since IMHO it is a good compromise that will improve readability while still keeping the better performance.

Just my 2 cents

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-team-core mailing list