I was working on my website written in php/mysql. When I first wrote it, it was spaghetti with lots of php embedded in html and the like - very hard to maintain.
I rewrote the whole thing with a nice modular structure with OOPS, and now it is much easier to maintain and expand.
But when testing the site performance using webwait and siege, the newer, better structured version seems to run and load slower than the spaghetti code version.
There's a difference of nearly 1 second in loading time - 2.39s vs 3.81s
Nothing else was changed except the php code - not the js, not the css
So what is the problem here? Should I revert back to the old code? Has this happened to others?
Edit:
- I have done some analysis using
cachegrind, inclued and I think the
code is pretty good.
- I also
know that the problem is not entirely
OOPS but the greater structure etc.
and also that OOP doesn't at all
guarantee better performance.
- I have run the code multiple times too.
- I've used cachegrind with
kcachegrind, inclued, siege (most of
the tools Rasmus lerdorf outlined in
his drupalcon 2008 talk on 'Simple
is Hard')
What I want to know is how others deal with this.