Thursday, August 7, 2008

PHP Performance Optimization

In every development cycle there comes the time, when you've got to optimize things. I really love the following article: guys & iris: you should all have a good read of http://c2.com/cgi/wiki?PrematureOptimization about this topic.

It clearly explains and lays out why it is the best to:
  1. Make it work.
  2. Make it right.
  3. Make it fast.
in exactly that order. To be even more precise it says:
  1. Make it work.
  2. Make it right
  3. Make everything work.
  4. Make everything right.
  5. Use the system and find performance bottlenecks.
  6. Use a profiler in those bottlenecks to determine what needs to be optimized.
  7. Make it fast. You maintained unit tests, right? Then you can refactor the code mercilessly in order to improve the performance.
So, I think we've hit that 2nd/4th point now. As you know from one of my last blogs, I massively like my MacBook. So of course, I'm not prepared to switch away for a simple performance analysis tool.

As you might be well aware, a typical combination to identify PHP bottlenecks is XDebug to log execution times and KCacheGrind to make them human-readable. Unfortunately, the installation process of KCacheGrind of Mac OS X is not that straight forward, although it's pretty straightforward :).

I've taken the following small tutorial from http://brent.izolo.com/blog/?p=4 and amended it where necessary.

  1. Install Fink. An excellent article on how to set up Fink on your Mac can be found in the O'Reilly macdevcenter. Check it out. Otherwise, you can just download the installable binaries for your version of Mac OS from the Fink homepage.
  2. install the X11 development package as hinted by this incredibly useful little tutorial:
    Installing X11 on OS X 10.4 Tiger. It's 5 years old, but still up to date.
  3. edit /sw/etc/fink.conf and add:
    unstable/main unstable/crypto
    to the Trees key. The line should now read like this:
    Trees: local/main stable/main stable/crypto unstable/main unstable/crypto
  4. Open the command-line and enter:
    fink selfupdate; fink index; fink scanpackages
  5. After the update and reindexing finished enter:
    sudo fink install kcachegrind
    in the command line
  6. Answer all the questions by the script and prepare for a looooooooooong configuration and installation time (many, many package dependencies)
To run KCacheGrind:
  1. start X11 (e.g. by using the Spotlight and searching for "X11")
  2. open the console and type:
    /sw/bin/kcachegrind
That's it (hopefully!). Enjoy.

Bests,
Charly

Labels: , , ,

Thursday, July 3, 2008

Piins Contact API - The data is the users'

We just don't agree that platforms have the right to claim possession over user data in terms of completely restricting them from accessing/deleting/editing all their data in the most efficient way. CAVEAT: "most efficient" does definitely not refer to the way some platforms (we don't want to point with fingers here) define "efficient", i.e. only via their own platform.

They might do a nice job to convince themselves that they are the best, and market valuation might suggest that they are, but all the data there is still the users'. We'd even go that far to say, that not only the direct data, but also all the inferred one is the users', although you can probably argue about that, so we'll cover that in another posting :)

Anyways, as part of our movement to make all data as accessible to their respective users, being extremely aware of privacy and data protection standards, we've released our little contact-import and message sending API.

If you are interested contact us anytime, we're happy to discuss how you can help users to access all their data as easily as possible (well at least, as our little Piin-brains can do, if we piin down the time :). We want to speak to you first to assure, that you are not going to misuse the API in any malicious or harmful way.

The link for the API is for testing only. WE DO NOT STORE ANY OF YOUR CONTACTS, NEITHER DO WE SPAM THEM. We hate spam ourselves and if we had a little bit more time, we'd be working on a giant fight-spam-forever project! This is why we disabled message sending via the Outlook upload as well. You will still be able to see the imported contacts directly after import from your Outlook CSV file, but not be able to send them messages.

P.S.: If your are interested in an internationalization library for PHP, we've developed one for Smarty in PHP. A tutorial for this library can be found here. We're planning to release many more APIs for the open source community and the startup community, so stay tuned with our blog.

Labels: , , , , ,

Friday, June 27, 2008

Install Sphinx on Mac OSX Tiger (10.4)

Hello everyone (especially developers),

I know, I know - you should NEVER use a development environment that is different from your deployment one, but I just can't help myself. I just love my Mac and don't want to replace my nice little black MacBook by a clumsy other one, just because I've to run a customized version of Gentoo on it :) - neither do I want to mess with BootCamp...

That aside, I've struggled for a little bit getting Sphinx (the incredible indexing and search engine) to work on my machine, a MacBook with OSX Tiger (10.4) on it. Maybe some of you are struggling with the same problem, so I thought I put a short tutorial together that helped me compile and run it successfully.

So here we go:
  • download version 2.5 of XCode from the Apple page. Version 2.5 is for Tiger (10.4).
  • install the X11 development package as hinted by this incredibly useful little tutorial:
    Installing X11 on OS X 10.4 Tiger. It's 5 years old, but still up to date.
  • download and install MacPorts (if you haven't already): http://www.macports.org/
  • open console and enter sudo /opt/local/bin/port install mysql5-devel
  • wait, wait some more, wait, wait, get coffee and wait
  • Download Sphinx and untar it to any directory
  • in the console, change to the directory you just untar'd Sphinx to
  • enter in console: ./configure --with-mysql-libs=/opt/local/lib/mysql5/mysql/ --with-mysql-includes=/opt/local/include/mysql5/mysql/
  • enter in console: ./make
  • enter in console: sudo ./make install
That should have done the trick!

Enjoy.

Bests,
Charly

Labels: , ,

Tuesday, March 18, 2008

First Piins OS release: Smarty & I18N

Yipiiieh, here we go. Our first public Piins open source release (MIT license). We've decided to release Smarty plugins that make life with Smarty and i18n easy (well, at least as easy as I18N can be per se).

Wolfram Schlich posted a nice overview of best practices to internationalize Smarty templates. His overview can be read in this mailinglist archive.

Unfortunately none of the provided best practices seemed to be compliant to the standard GNU i18n library gettext, as employed in many applications. Hence we thought about implementing our own, which turned out to be both - incredibly easy and very handy.

We would like to share this library with you including a little tutorial how to use it. The files for the i18n & smarty tutorial can be downloaded as well.

We've also hosted it on Google code as the Google code piins-smarty project.

Help us making the library better by posting the bugs you found :) ah and by the way, there are many more libraries to come, such as:
  • php-DAL: data access layer for PHP and MySQL, built on PDO. Allows stored procedure call with easy access
  • php-DAL-generator: auto generate the DAL (data access layer) for your MySQL database (including stored procedures).
  • php-MVC: a very lightweight MVC framework for PHP with complete i18n/L10n support
  • .NET enterprise libraries compiled for Mono on Unix systems
  • and much much more...
Enjoy & stay tuned!

Labels: , ,