[Solar-talk] Namespacing with concrete class functionality (was: Re: Proposal: Remove namespace to Solar::loadClass()/factory())

Rodrigo Moraes rodrigo.moraes at gmail.com
Wed Nov 8 00:11:38 PST 2006


Hey,
I've done some benchmarks. I'm not sure if these is a correct
benchmark, but it seems that there is a bad performance penalty (about
30% slower) when your Vendor is the primary namespace and you don't
have many class replacements in your vendor.

Here's the code I've run:

<?php
$time_start = microtime(true);
ob_start();
for($i = 0; $i < 100; $i++) {
    include 'index.php';
}
ob_end_clean();
$time_end = microtime(true);
$result = $time_end - $time_start;
echo '<h1>time: ' . $result . '</h1>';
?>

Results (100 times loading the Bookmarks app on my specific install)
-----------------------------------------
'namespaces' => array('Solar', 'Tipos'),
time 1: 26.853514909744
time 2: 29.44411611557
time 3: 28.421876907349
------------------------------------------
100x bookmarks
'namespaces' => array('Tipos', 'Solar'),
time 1: 40.197156190872
time 2: 40.61256980896
time 3: 38.761080980301
-------------------------------------------
no namespaces (Solar 0.25)
time 1: 25.208446979523
time 2: 25.127389907837
time 3: 25.47754406929

Environment: Apache 2 + PHP 5.2 + MySql 4.1 on Windows XP, no opcode cache.

I thought that looping an app would give a better idea of the
namespace implementation impact. I haven't tried to benchmark
Solar::loadClass() isolated.

What do you think?

rodrigo


More information about the solar-talk mailing list