Web Tool Bag  
Home · Articles · Downloads · Discussion Forum · Web Links · News CategoriesSeptember 09 2010 04:03:38
Navigation
Home
Articles
Downloads
Discussion Forum
Web Links
News Categories
Search
Users Online
Guests Online: 3
No Members Online

Registered Members: 214
Newest Member: aloyskimbe
Forum Threads
Newest Threads
Unix Servers
downloads
Validation on the re...
letters not working
When I input the wro...
Hottest Threads
Installation [11]
Captcha picture d... [4]
Any questions and... [4]
Integrate with Vi... [3]
How to include it? [3]
Latest Articles
PHP obfuscation usef...
Apache2 speed up
How to Optimize Loops
How to Fix Performan...
How to Understand Pe...
How to Optimize Loops
Sometimes you'll encounter loops, or recursive functions, that take a long time to execute and are
bottlenecks in your product. Before you try to make the loop a little faster, spend a few minutes
considering if there is a way to remove it entirely. Would a different algorithm do? Could you
compute that while computing something else? If you can't find away around it, then you can optimize
the loop. This is simple; move stuff out. In the end, this will require not only ingenuity but
also an understanding of the expense of each kind of statement and expression. Here are some suggestions:

• Remove floating point operations.

• Don't allocate new memory blocks unnecessarily.

• Fold constants together.

• Move I/O into a buffer.

• Try not to divide.

• Try not to do expensive typecasts.

• Move a pointer rather than recomputing indices.

The cost of each of these operations depends on your specific system. On some systems compilers
and hardware do these things for you. Clear, efficient code is better than code that requires an understanding
of a particular platform.

Posted by zdravko on July 12 2010 10:36:15 145 Reads · Print
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Member Poll
Which PHP framework do you preffer?

Symfony

Zend

PHPDevShell

PHP on TRAX

eZ Components

Fusebox

PhpOpenbiz

Prado

QPHP

Seagull

You must login to vote.
Shoutbox
You must login to post a message.

No messages have been posted.
manual submit | PHP Obfuscator
Copyright © 2010 - www.webtoolbag.com