Welcome Guest, Not a member yet? Register   Sign In
Tips for faster CI Applications
#1

[eluser]Mareshal[/eluser]
I am creating this thread because of this: http://ellislab.com/forums/viewthread/123293/#610549 and some CI beginners really need some helpful tips about faster applications, using CI.

Any sugestions? Post here any helpful tips.

thank you
#2

[eluser]Yorick Peterse[/eluser]
As stated earlier, there are a few ways of improving the speed of your applications :

- Use a cache system
- Optimize your PHP code :

Code:
<?php

// This...
$num_rows = $query->num_rows();
if($num_rows > 0)
{
    // Do something....
}

// Is faster than this
if($query->num_rows() > 0)
{
    // Do something....
}
?>

- Use CSS sprites
- Use subdomains for images, styles etc (therefore it can all be downloaded at the same time)
- Compress images
#3

[eluser]Mareshal[/eluser]
"Use subdomains for images, styles etc (therefore it can all be downloaded at the same time)"
all my imagea are loaded from root/style/... every css file and ikmages related has a folder inside.

should I put all my images in images.mydomain.com, but is the same thing.

"CSS Sprites", I don't use something like style="style here" in html, only for special requests, depedi9ng on information coming from database.

but tips related to code igniter? config, autoload etc?
#4

[eluser]Andreas Bergström[/eluser]
- Use image sprites (http://paulstamatiou.com/how-to-optimize...ge-sprites & http://www.alistapart.com/articles/sprites)
- General PHP does and don't does (http://www.hm2k.com/posts/50-php-optimis...-revisited)
- Don't use Javascript where you could use CSS (image-rollovers etc.)
- Don't overload the client with cookie-data, server-side storage of temporary data can sometimes be faster. (Cookie amount and size limitations --> http://www.nczonline.net/blog/2008/05/17...trictions/)

[quote author="Yorick Peterse" date="1248018830"]
- Use subdomains for images, styles etc (therefore it can all be downloaded at the same time)
[/quote]

Can you please explain the second one, not really sure what you mean and I've never heard it before. Smile


Edit: Fixed links...
#5

[eluser]slowgary[/eluser]
Yorick...

Why is the second if() faster?
#6

[eluser]ggoforth[/eluser]
[quote author="slowgary" date="1248054750"]Yorick...

Why is the second if() faster?[/quote]

I think he's saying the second if is slower. Which seems strange as the first requires two evaluations, while the second only requires one. Anyone know why the first if in Yorick's post is faster?

Greg
#7

[eluser]slowgary[/eluser]
That's what I meant, the first. The first also uses an additional variable, which I suppose *could* translate to additional memory usage. Maybe the first is more multi-threaded?

Anyone?
#8

[eluser]Andreas Bergström[/eluser]
[quote author="slowgary" date="1248054750"]Yorick...

Why is the second if() faster?[/quote]

No, he says the second one is slower. The reason is in the first one num_rows get executed only once and stored in a variable. In the second one num_rows is executed every single loop, which obviously is less effective (since the number of rows in the returned sql query is static).
#9

[eluser]ggoforth[/eluser]
[quote author="Andreas Bergström" date="1248055629"][quote author="slowgary" date="1248054750"]Yorick...

Why is the second if() faster?[/quote]

No, he says the second one is slower. The reason is in the first one num_rows get executed only once and stored in a variable. In the second one num_rows is executed every single loop, which obviously is less effective (since the number of rows in the returned sql query is static).[/quote]

In his example I don't see any loop involved. I know when I use this kind of coding it's to check and see if a database resource exists (anything was selected) before running the result through a loop. In that case (where there is no loop involved) is the first if() still faster? It's more code, and more evaluations to complete, so it seems like it would be slower. I'm certainly not an expert on this kind of thing, so this is mostly just what it looks like on the surface to me. Smile

Greg
#10

[eluser]slowgary[/eluser]
I agree ggoforth. I would see the value of storing the num_rows in a variable if it were inside a loop, that seems obvious. In the example though, it does not seem so obvious that the first if() would be faster.

Maybe Yorick has been drinking with his party hat on again?




Theme © iAndrew 2016 - Forum software by © MyBB