MythBusters• They get a Myth• Break it down to its different parts• They Conduct a Bunch of Tests• They Draw Conclusions• and have a Fun Time
Developers• We get Myths (Hey, this is slow)• We Break it down to the different pieces• We Conduct a Bunch of Tests.• We Draw Conclusions (and normally make changes)• and Have a Fun Time...
So Lets Get Started! php /lets/get/started.php now
First Off, Some PHP Myths and there are a lot of them!
Common Performance Claims (Myths)• echo instead of print() • single quotes, not double quotes• echo commas, not periods • include instead of include_once• don’t use custom functions/classes • === faster than ==• pass by reference • for faster than foreach instead of by value
MythBusters Tested• Keeping Your AC Off vs Windows Down• Idling Better than Stop/Start• Magical Aerodynamics• Dirt-Free Filters• Special Fuel Additives to Slow Burn All Busted! They Didn’t Make a Difference, Or Worsened Fuel Efﬁciency
How About Driving Angry? After Testing, Tory & Grant Used33% More Fule While Driving Angry
XHProf• Developed by Facebook• Works well for both Development & Production* Proﬁling• pecl extension• Decent UI for viewing Results * - Use Sampling & Special CPU Flags for Production http://mirror.facebook.net/facebook/xhprof/doc.html
XHGui• Improved GUI• Easy to Setup• Built In Sampling• Advanced Conﬁguration• MySQL Backend• I recommend using this! https://github.com/preinheimer/xhprof
Xdebug Proﬁler• Install Xdebug• Enable Xdebug Proﬁling• Outputs a Cachegrind Log• Use KCachegrind / WinCachegrind / Webgrind to view• For the Rich, MacCallGrind for $150
Enabling Xdebug Proﬁlingxdebug.proﬁler_enable=1xdebug.proﬁler_output_dir=/tmpxdebug.proﬁler_output_name=cachegrind.out.%p Xdebug Proﬁling Not for Production (unless you have a 100TB HDD laying around)
vmstat• swap > 0 means swapping Memory Issue• cpu sys + us really high CPU / Code / PHP Problem• cpu wa > 10 Disk IO Problem* * - Technically could be Network IO as well, but typically one of the last and more rare bottlenecks to hit