SHAD Posted January 3, 2011 Posted January 3, 2011 Hey all, Once i have finished working on my site mods etc, then i want to then go through the entire code to make sure it's efficient and uses less resource ect. The current methods i am aware of are... Instead of print use echo as it's slightly faster. Only select whats needed from the database. Try to separate variables from the strings . Like echo ' hello, $Var '; Don't use sprinf as it slows down the code. Use Arrays for data as it's faster to grab. Don't use too much PNG images. What do you guys think of the above, and what other small or big things need to be taken in to acccount? Quote
Spudinski Posted January 3, 2011 Posted January 3, 2011 In order... It's also called "Optimization", not optimism. 1. By a few nano seconds, wouldn't actually notice it. 2. Yes, only selecting what you need from the database speeds up queries. 3. Same as 1. 4. Same. 5. Not really allot, array's is mostly used because it's easier to manage on a large scale. 6. On the contrary. PNG is the smallest between GIF, JPEG and BMP. With most aspects of MCCodes, optimization isn't really a big factor unless you have a hefty amount of users(10k+). The only thing you need to worry about is being able to push content to the user as fast as possible. EDIT Danny, using sprites only reduces the number of HTTP requests required. It makes the website load somewhat faster, but the images are actually larger(not by allot, but they still are). Quote
Dominion Posted January 3, 2011 Posted January 3, 2011 http://www.phpbench.com/ I love that site. Quote
SHAD Posted January 4, 2011 Author Posted January 4, 2011 Thanks guys, @Danny 'Sprite', Thanks for this idea, i have tried it on some big images and the results are clear to speed. @Spudinski, Thanks for the correction mate, i always thought png was the hardest to load, due to it being good quaility. @Dominion, Thanks for the webiste mate, i have learnt some more ways. Thanks Guys :thumbup: Quote
Diesl Posted January 4, 2011 Posted January 4, 2011 6. On the contrary. PNG is the smallest between GIF, JPEG and BMP. Mostly true, but not always. - Try to stay away from nested loops (especially with query's inside them). They might seem harmless at first, but they can unknowingly grow and take up quite a bit of resource usage. - Try to keep the page size as small as you can. Use global functions to perform repetitive tasks. Quote
SHAD Posted January 4, 2011 Author Posted January 4, 2011 6. On the contrary. PNG is the smallest between GIF, JPEG and BMP. - Try to keep the page size as small as you can. Use global functions to perform repetitive tasks. In this case would you say it's best to spread the code in more then 1 file, just to make sure the page size remains small? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.