0 ; $i--) { $theme = 'theme' . $i; $base_theme = 'theme' . ($i+1); $temp_theme = new clsTheme; $temp_theme->base_theme = $base_theme; $themes[$theme] = $temp_theme; } unset($themes['theme' . MAX]->base_theme); $theme = 'theme1'; //print_r($themes); // Original method $t1 = microtime(true); $base_theme = array(); $ancestor = $theme; for ($i=0 ; $ibase_theme)) { $ancestor = $themes[$ancestor]->base_theme; $base_theme1[] = $themes[$ancestor]; } } $t1 = microtime(true) - $t1; //print_r($base_theme1); // Suggested method $t2 = microtime(true); $base_theme = array(); $ancestor = $themes[$theme]->base_theme; for ($i=0 ; $ibase_theme; } } $t2 = microtime(true) - $t2; //print_r($base_theme2); echo "Original method : " . $t1 . " ms\n"; echo "Suggested method: " . $t2 . " ms\n"; echo "Ratio = " . ($t1 / $t2) . "\n"; echo "Gain = " . (int)((100 * ($t1 - $t2)) / $t1) . "%"; ?>