Eliminating Benchmarking and Hooks in CodeIgniter for Speed Improvement

Out of curiosity, I did a few tests on PHP 5.2.5 locally to see if the already zippy CodeIgniter could be sped up or made more efficient by removing Extension Hooks and the Benchmarking class, which occasionally get criticized for always being loaded and called even when the user is never taking advantage of the two classes.  Hold on to your hats…

My controller is simple:

  1. $this->output->enable_profiler(TRUE);
  2. echo 'Hi there!';

And the results:

  1. /*
  2. NORMAL
  3. Total Execution Time 0.0172
  4. 689,672 bytes memory
  5. NO HOOKS
  6. Total Execution Time 0.0153
  7. 666,536 bytes memory
  8. NO BENCHMARKING
  9. Total Execution Time 0.0179
  10. 685,360 bytes memory
  11. */

Now of course, the Heisenberg uncertainty principle is at play here, particularly with the last test.  How can you test the speed gain of the removal of code that measures how long the application takes to run?  I removed the class call, and replaced the markers where it measures the start and stop of application processing with microtime() and did some subtraction.  Not a whole lot less than what the Benchmark class does itself, but it is removing the class and overhead of the calls to it, hence the fractional drop in memory consumption.

Your results may, nay, will vary, and these things are always impossible to make firm statements about, but I think it sufficiently demonstrates that if you are worried about either of these two classes making your application inefficient, that you’d do better to look at and worry about your own application code, and having a quality host, both of which will certainly have a measurable impact on your site’s performance.

ExpressionEngine 1.6.4 and CodeIgniter 1.6.3 Released

ExpressionEngine version 1.6.4 has been released, and so has CodeIgniter version 1.6.3.

These are both security and maintenance releases recommended for all users.  Big thanks to CI community member Pascal Kriete (Inparo), for helping us identify and patch up a potential cross-site scripting vector.  He showed both a tremendous aptitude for security issues, but also a mature responsibility in how he chose to communicate these issues he helped find.  Definitely a CI community member to keep your eye on.

My Day With the New Spaces

If you’re just looking for the quick opinion and don’t want to read on, here’s the verdict: the new Spaces behavior in OS X 10.5.3 is golden.  I’m a 24-hour convert.

Spaces is of course, one of Apple’s features new to OS X 10.5 Leopard that allows you to have multiple virtual displays that you can switch to at will.  Apple did not invent this concept, as it’s been around for quite some time as "virtual desktops" in most Linux GUIs using a "pager" to switch between desktops, and on Windows with third party applications that function similarly to the Linux take on it.  Apple does innovate often, creating small features that truly change how I use my computer (Exposé, Quick Look, Time Machine, spell checking and correction OS-wide).  But when they adopt an existing technology, they traditionally transform it into something elegant that also fits that pattern.  In its original incarnation, Spaces didn’t do that, at least not for me.  It felt like a me-too feature taken from other GUIs, that while useful in concept, did not bring Apple’s touch of elegance and usability to make it worthwhile.

Essentially, Spaces’ virtual desktops separated things by application, not by task.  So a jump to Safari would pull you away from your current workspace and into one where Safari was already open.  I tried, really hard, to use Spaces to help me be more productive, and after forcing myself to use it for a couple of days, I dropped it and disabled it.  In order to use Spaces, I had to think about using Spaces.  A solid and useful OS feature should blend into the background and your subconscious, and simply exist, and help you be productive.  It shouldn’t be something you have to think about using, taking mental clock cycles away from getting things done.

Well, enter the new checkbox option in the Spaces Preferences in 10.5.3 labelled "When switching to an application, switch to a space with open windows for the application." John Gruber’s piece was the first place I read about this new change, but my previous experience was so sour I was skeptical. It wasn’t until yesterday that I decided to try it again, disabling that checkbox.  I commented to Derek Allard that it sure would be nice if I could make certain windows persistent across all Spaces, since it would be a pain to switch to another Space to answer every instant message that I receive throughout the day.  And of course, Apple has you covered there, allowing you to assign applications to specific Spaces, or to exist in every Space.  This is not a new feature, but combined with the behavioral change, it became the perfect blend-into-the-background feature I was looking for.

I now have four Spaces, one for Mail and NetNewsWire, one for my main browser and current tasks, another with CodeIgniter in TextMate with browser windows open to that local install, and a fourth with ExpressionEngine 2.0 in TextMate with browser windows open to that local installation.  Adium floats with me to all Spaces.  And if I open a link in Mail or NetNewsWire, Safari will open in that very space instead of jumping to another.  I used to use the Dock heavily for application switching, but I find my hands leaving the keyboard even less now with a simple, ctrl+arrow to switch to a different Space.  I still use the Dock on occasion, and clicking it will activate the application in the current Space, and successive clicks will take me to other Spaces that that app already has open windows.  I love it, love it, love it.

So that’s the long version.  Spaces with its default behavior is a no-go for me, actually making me less productive by forcing me to work the way Spaces wants me to work.  The new optional behavior makes Spaces behave exactly as my mind expects it to, and has empowered me to separate virtual desktops by task, not by application.  I’m contemplating adding two more Spaces right now, and giggling at the idea of six+ 24" workspaces at my disposal.

Life is Like a Bowl of Cherries

Our very kind neighbor has a plethora of fruit trees, including a North Star sour cherry tree.  Their trees produce more fruit than they can use, and they have graciously allowed us to pick and consume what we would like to use.  And the birds and deer still have enough to get their full share.  In just a few minutes, Rochelle and I had gathered about a gallon of these tart beauties.  Click for the full size, less optimized version to see the true color and brilliance!

image

image

image