Tuesday, July 25, 2006

Nice PHP Object tips

I love PHP and PHP objects. If you do too, here are some tips for speeding things up from the people at http://www.whenpenguinsattack.com:

The following tips can help in optimizing object-orientated PHP.

1. Initialise all variables before use.

2. Dereference all global/property variables that are frequently used in a method and put the values in local variables if you plan to access the value more than twice.

3. Try placing frequently used methods in the derived classes.

Warning: as PHP is going through a continuous improvement process, things might change in the future.

More Details

I have found that calling object methods (functions defined in a class) are about twice as slow as a normal function calls. To me that’s quite acceptable and comparable to other OOP languages.

Inside a method (the following ratios are approximate only):

1. Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function.
2. Incrementing a global variable is 2 times slow than a local var.
3. Incrementing a object property (eg. $this->prop++) is 3 times slower than a local variable.
4. Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one.
5. Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists.
6. Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance.
7. Methods in derived classes run faster than ones defined in the base class.
8. A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations.

Friday, July 21, 2006

This Goes Out To 1% Of The People

There is a great article from the Guardian (http://technology.guardian.co.uk/) that says that 1 out of 100 people create content. 10 out of 100 comment and interact and the remaining 89% sit and listen. This is a stat that I believe holds water. While it may seem odd that the Internet is called an interactive medium even though the huge majority like to watch. Compare this 1:10:89 ratio to a community newspaper. Fifteen people put out 10,000 copies and each issue generates 200 pieces of reader mail. Old media in this example has a 15:200:10,000 ratio. The creator/comment numbers compare to one another between old and new media, but old media has a reader ratio of 8 times more passive participants. That's why new media is considered interactive and terms like "narrowcasting" are used.

Monday, July 17, 2006

Monday, July 10, 2006

Amazon: 1 Click From Nowhere

I've been waiting for this book from an used "seller" (I quote "seller" because sellers give items in exchange for money; thieves do not; so the jury is out), dvdlegacy_ca (seller profile). I asked the seller about this and got no reply. I then asked Amazon what I could do. I used their web form because Amazon doesn't like making their contact information known. You'd think they were selling Hoodia or Cialis.
After I hit "send" on their web form, I got an email. I thought, "Wow. That was fast"

This is what I got:

This is a MIME-encapsulated message

The original message was received at Mon, 10 Jul 2006 10:47:25 -0700
from nobody@localhost

----- The following addresses had permanent fatal errors -----
@amazon.ca
(reason: 553 5.1.3 <@amazon.ca@amazon.com>... Invalid route address)

----- Transcript of session follows -----
... while talking to smtp-in-5102.iad5.amazon.com.:
>>> DATA
<<<><@amazon.ca@amazon.com>... Invalid route address
550 5.1.1 @amazon.ca... User unknown
<<<><@amazon.ca@amazon.com>... Invalid route address
Last-Attempt-Date: Mon, 10 Jul 2006 10:47:25 -0700

---------------
07/10/06 10:47:25
NAME: Mike DeWolfe
ORDER NUMBER: 058-8348299-3787XX6
COMMENTS: I placed this order on June 16th. It's estimated delivery window was June 16th to July 7th.
I understand that the seller was supposed to ship it within two days of receipt of the order. Three weeks seems like a long time, even for something sent by surface mail.
If it has not arrived by July 12th, how do I begin the process to have the order refunded?

Thank you,

Mike DeWolfe


Congratulations to Amazon.ca for shoddy service. They can't even process their own web forms. That's a stupid human trick that was perfected circa 1996. Amazon's only strength is its size. If Google and Google Checkout find a way to wade into this marketplace, Jeff Bezo's house could go up for auction on eBay-- er, Google Base, soon.

Monday, July 03, 2006

Pay Per Post: Profit Not Payola

Monetizing the Internet. It's equally considered a violation of the sacred digital highway; and a neccessity to move it from long term experiment to viable commercial medium.
Way back in the 1990s, people put banners on their pages and reaped in 10¢ per click. Then click-fraud went rampant (who thought a web site owner would click on their own links?); the advertisers found that they didn't get their dime's worth and the price plummeted to well below a penny per click. Google Adsense has come along with a refined model and a streamlined execution. Like all pyramid schemes: 1% of the people are making 99% of the money. Adsense gurus are showing off how to make $6,000 per day, but many schmoes out there are making only $0.02 per day.
If the economies of scale content (lots of people paying a little money) doesn't work, there has to be another model to follow. I have long been a fan of the patron system. Someone commissions you to perform a work for them. It's their dime and you take note of that when you do it. It's still the economy of scale concept, just far fewer people are paying much more money.
Enter http://www.payperpost.com. This is a website that registers bloggers and gives them assignments. Ironically, I found out about this via a CNet column slamming the concept (I won't burden you with a link to that commentator's drivel). It's ironic, because the blogger who is criticizing Pay Per Post, is getting paid to post his work. If people were not able to post to the Internet and eke out a living, many fewer people would do so. That's the problem with the Internet: because there is little cash in play there is no incentive to stop "regular" work and post on the Internet. Pay Per Post offers a remedy. They hand out assignments to their bloggers, the bloggers write a piece on that subject. There is a spin requested (postive or neutral usually). There is always spin in everything written. When I was doing movie reviews I knew there were two ways to spin a mediocre movie: savage it and alienate the distributor; or critique it-- show the flares and the flaws-- with the idea that all publicity is good publicity. Even if I tore it to shreds, I still got to see it for free. Indeed, if I get a book review, I usually get to keep it-- that's a $10-100 book that I might not have purchased. This isn't payola. This is monetization. I am taking what I am given and putting my opinion around the subject. I have never held my nose and given a stinker a good review.
I am hoping that Pay Per Post has a future because it promises to couple effort with money and that is at the heart of the capitalistic system were live under.