› performance

» PHP "is_whitespace" performance
Fri, 08/22/2008 - 00:09
Easy question: What is the fastest way to determine if a string in PHP is whitespace-only?
Easy answer: !preg_match('[^\s]', $string);
Read on for the explanation:
» profile.class.php
Tue, 06/24/2008 - 18:29
Every now and then I want to profile a given part of PHP code. For example I want to quickly check wether my current changeset to GeSHi works faster or is horribly slower. For a big change I’ll stick to Xdebug and KCachegrind. But for a quick overview? Overkill in my eyes.
Say hello to profile.class.php, a simple timer class for PHP5 which you can use to get an overview about where how much time is spent. This is in no way a scientific method nor should you take the results of a single run as a basis for you decisions.
I’ve set an emphasize on an easy API so you don’t have to pollute your code with arbitrary hoops and whistles.
UPDATE: You can find the current updated source in the SVN repo of GeSHi.