Archive for April, 2010

Fixing Doctrine’s Geographical template precision

Tuesday, April 27th, 2010

(Note that this blog post is about Doctrine 1.2. At the time of this minor update—Nov 16, 2010—I can’t seem to actually FIND a Geographical behavior in Doctrine 2. So, if you’re using Doctrine 2, this post probably isn’t for you. It sucks, I know, this behavior was friggin’ handy.)

Doctrine, an ORM library, has a convenient little behavior that you can attach to your tables to give them awesome superpowers of geolocation. It’s the Geographical template, and it resides in Doctrine/Template/Geographical.php. What it does is add two fields to your table: Latitude and Longitude, and extends your model with the ability to discern distances between any two of these locations.

That’s all well and good, except that as of 1.2.2, Doctrine’s default precision for a floating point field is 2. That doesn’t allow for very accurate geolocation, as it truncates something like “+33.544622″ down to “33.54″. Not good.

(more…)

PHP hashing performance experiment

Sunday, April 25th, 2010

Today, in the never-ending quest to tweak server performance by a few milliseconds, I decided to do a bit of testing of various php hashing methods. I therefore wrote a quick script under php (5.2.11 currently, I need to update), which ran each test case 10,000 times to achieve a decent min/avg/max for each case, on strings of 10KB, 100KB, and 1,000KB in size.

(more…)