Code optimization

16 years 7 months ago #44581 by SeaPirate
Code optimization was created by SeaPirate
Hi!
Thanks for the great component! I wonder if the CB developers intend to optimize the code in the coming versions by for example setting the output to the output variable and then echo-ing only once. For example:
[code:1]
$output = "bla bla";
$output .="more more";
$output .="even more";
echo $output;
[/code:1]
Cheers
/SeaPirate

Please Log in to join the conversation.

16 years 7 months ago #44635 by mikko
Replied by mikko on topic Re:Code optimization
Just out of curiosity: What would this optimize and what would the impact be?

-Mikko

Please Log in to join the conversation.

16 years 7 months ago #44746 by ford
Replied by ford on topic Re:Code optimization
Not sure what the impact is, but I stumbled over this:

phplens.com/lens/php-book/optimizing-debugging-php.php

The second issue is that in PHP 4, echoing multiple times is slower than storing everything in a string and echoing it in one call. This is because echo is an expensive operation that could involve sending TCP/IP packets to a HTTP client. Of course accumulating the string in $s has some scalability issues as it will use up more memory, so you can see a trade-off is involved here.


Ford

Please Log in to join the conversation.

16 years 7 months ago #44786 by beat
Replied by beat on topic Re:Code optimization
Multiple TCP/IP packets is only true if you don't have buffering on, and joomla and mambo are working with buffering on. So it's not an issue. Appending long strings can be consuming too.

Don't think that it's an issue, but would consider any reproductible benchmarks :)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

16 years 7 months ago #44941 by SeaPirate
Replied by SeaPirate on topic Re:Code optimization
Thanks for the answers :) !!!
I haven't done any benchmarking on Community builder but I've noticed that other Joomla components use to be written in this style :silly:. Anyway, interesting question.
Cheers and thanks once again!!!

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.234 seconds

Facebook Twitter LinkedIn