I work for a company, and they have an internal product. Some of the functions of this product are to build semi-complex reports, which should probably take longer just to transfer the HTML than it would to generate them. It ran terribly slow, however, so I was tasked to look into it. I found such gems as:
function dbconnect($resource){
return(dbconnect($resource));
}
The biggest issue wasn't even that. There is an object builder, which builds an object composed of dozens of other objects. Each of these objects is then composed of dozens of other objects, and so on down the list. The whole thing is about 5 levels deep. I used xdebug to profile the code, and determined why it was running so slow. After running the report and opening the profile in WinCacheGrind, I found that it was making over 85,000 calls to the database. That's correct, you read it right, 85,000. This wasn't some mega complicated procedure, either, it was simply building an array of things and displaying them.
Luckily, after rewriting some of the classes to build the objects, the number database calls have been reduced to 11.