Search results

From the blog

Posted 2010-08-17
Autoloading Benchmarks

During the past week, I've been looking at different strategies for autoloading in Zend Framework. I've suspected for some time that our class loading strategy might be one source of performance degradation, and wanted to research some different approaches, and compare performance.

In this post, I'll outline the approaches I've tried, the benchmarking stategy I applied, and the results of benchmarking each approach.

From the blog

Posted 2008-01-01
2007 Retrospective

2007 was a busy year, both personally and professionally. I won't go into the personal too much, because, well, it's personal, and some of the details are simply inappropriate for blogging material.

Here's the short version:

  • One trip to Belgium and The Netherlands.
  • Two trips to Israel.
  • Two trips to Atlanta, GA (not counting the return trip from Europe, when I was stranded for a day due to storms in the Northeast).
  • Three different user groups attended, with three presentations.
  • One major Zend Framework release
  • One PEAR release.
  • One podcast.
  • One webinar.
  • One book published.
  • One conference attended.

What follows is my month-by-month breakdown:

From the blog

Posted 2007-07-05
File_Fortune refactored

Over the past few evenings, I've refactored File_Fortune to have it implement Iterator, Countable, and ArrayAccess — basically allowing it to act like an array for most intents and purposes. As a result, I've eliminated the need for the File_Fortune_Writer package, and greatly simplified the usage.

(Note: sure, File_Fortune may not be that big of a deal, but over 1000 downloads in the past two years indicates somebody is using it. Plus, it powers the random quotes on the family website. :-) )

As some examples:

require_once 'File/Fortune.php';

// Initialize and point it to a directory of fortunes
$fortunes = new File_Fortune('/path/to/fortunedir');

// Retrieve a random fortune 
// (works with either a directory or a single fortune file)
echo $fortunes->getRandom();

// Set to a specific fortune file:
$fortunes->setFile('myfortunes');

// Loop through and print all fortunes
foreach ($fortunes as $fortune) {
    echo str_repeat('-', 72), "\n", $fortune, "\n\n";
}

// Hmmm.. let's change one:
$fortunes[7] = "I never really liked that fortune anyways.";

// No need to explicitly save, as it's done during __destruct(), 
// but if you really want to:
$fortunes->save();

// Let's add a new fortune:
$fortunes->add('This is a shiny new fortune!');

// and now we'll verify it exists:
$index = count($fortunes) - 1;
echo $fortunes[$index];

All-in-all, it's a much better interface. Lesson learned: when porting code from other languages, it pays to take some time and determine if there might be a better API in your own.

In upcoming releases, I hope to modify the backend to use PHP's Streams API instead of direct file access, and also to allow providing a list of fortune files explicitly. After that, I should be ready for the initial stable release.

Update (2007-07-10): fixed parse error in examples

Search tips

  • Use #{some tag} or tag:{some tag} to filter by tag; using this more than once will find results that match all tags.
  • Use year:{year} to filter by year. If you use this multiple times, the last one wins.
  • Use begin:{year-month-day} to restrict to results beginning on that day. Last one wins.
  • Use end:{year-month-day} to restrict to results ending on that day. Last one wins.