Welcome Guest, Not a member yet? Register   Sign In
CI-based Web Sites Performance
#21

[eluser]Edemilson Lima[/eluser]
Quote:but what the hell were the developers thinking when they coded db->result()?

I agree with you. I talked about this issue in this thread:

http://ellislab.com/forums/viewthread/67663/

We can use $this->db->_fetch_object(), but this function could be not private anyway. We can use it in our views and code there the necessary loops. There is no problem in using loops at the views, since they are part of the presentation logic.
#22

[eluser]Lewis[/eluser]
Exactly, and if you use the view's loop system, you're looping through it 3 times. Whereas by passing it straight to the view, you can then use the view to manipulate the data (eg. change date formats) and you've not only eliminated the need to loop through it 3 times, but you've put more of the presentation logic in to the view.

I like CodeIgniter because it's simple and well documented, but it seems to be aimed at being too simple. Just small extra things like this would help make it so much more powerful for those with complex applications.

Whilst I'm at it, why does the session library hold a reference to CI? This creates recursion. I'm not too sure, but I think recursion also can't be good for memory usage. A quick look on Google shows that it may create a memory leak up to version 5.3. The weird thing is, no other libraries seem to have this, so why do it to the session library?
#23

[eluser]Edemilson Lima[/eluser]
I am using the Native Session instead. It works fine and allow me to store how much user data I want.
#24

[eluser]Lone[/eluser]
Interesting link to do with php performance...

http://sebastian-bergmann.de/archives/74...3-CVS.html
#25

[eluser]Nick Husher[/eluser]
[quote author="stanleyxu" date="1202580622"] (Is there a "copy-on-write" semantic behind PHP?)[/quote]

Yes. An assignment operator passes by reference until you attempt to modify the data at the other side of that reference, at which point PHP will duplicate the data in memory and make the change on the new copy. I don't think it requires any additional contemplation over Java's "everything's a reference" method, or C's "everything's a value (except pointers)" approach. All three can get you in trouble if you aren't thinking about them clearly.
#26

[eluser]beemr[/eluser]
[quote author="Lewis" date="1202617719"]For example, using CI a result-set of 500 is returned, which is looped through by the database class, then my model to apply some formatting, and then the form helper to create a dropdown. That's 3 times, when it can all easily be done in one.[/quote]
I think the problem with progamming that holds speed as an ultimate goal is that there is the temptation to do it all in one go. That can lead to some rigid, linear processes that don't leave many openings for others to get involved or even to take over.

Web work is simply too multifaceted yet to safely pursue speed for its own sake. A little separation of labor goes a long way towards keeping a site live versus speed gains otherwise, even when doubled or tripled. I like the balance CI draws between speed and separation. Back when Java and .NET were going at it (I presume they're still fighting, but who's watching?), .NET used to trump its speed. It turned out that the advantage was mostly achieved through stored procedures on the SQL Server. How would you like to go begging your SQL admin everytime you wanted to add a new feature to your web app?

That being said, I do have to admit that every time I find myself making a second loop, I simply turn my first result set into a more complex object just to get rid of the extra loop. A small bargain with the devil, I think.
#27

[eluser]Nick Husher[/eluser]
Indeed, beemr has hit upon the issue of premature optimization, an antipattern in software design. If you worry too much about speed at the outset, you're probably going to sacrifice maintainability and extensability for it. It's a better practice to start with something that's a little slow but easy to modify so that you can rapid prototype many approaches to the same problem. When you've hit upon the optimal solution, you can run some metrics and figure out where your greatest speedup will be and focus on that at the end.

Premature Optimization
#28

[eluser]Elliot Haughin[/eluser]
Hey guys, it's been great reading through this and getting everyone's opinions about performance and optimization.
I'm going to use this as a base for a comprehensive blog entry on the topic... with some quantifiable benchmark results to illustrate the best scaling practices.

Stay tuned.

Elliot
#29

[eluser]Edemilson Lima[/eluser]
Quote:Premature Optimization

I think your link to Wikipedia is wrong... I did find it here.
#30

[eluser]Pascal Kriete[/eluser]
That's wrong as well, this url is impossible to post on the forums
Go here, click on the computer_science one and scroll down to 'When to optimize'.




Theme © iAndrew 2016 - Forum software by © MyBB