public static function get($n) { Profiler::start(__METHOD__); if ($n < 2) { Profiler::end(__METHOD__); return 1; } $value = self::get($n - 1) + self::get($n - 2); Profiler::end(__METHOD__); return $value; }
/** * Should Return the N-th Fibonacci number * * @param $n * * @return int */ public static function get($n) { Profiler::start(__METHOD__); if (isset(self::$valueCache[$n])) { Profiler::end(__METHOD__); return self::$valueCache[$n]; } self::$valueCache[$n] = self::get($n - 1) + self::get($n - 2); Profiler::end(__METHOD__); return self::$valueCache[$n]; }
<?php require_once 'autoload.php'; include 'static/top.php'; use GedasTheEvil\Profiler\Profiler; use GedasTheEvil\Product\FibonacciNonOptimized; $test = basename(__FILE__); Profiler::start($test); FibonacciNonOptimized::get(30); Profiler::end($test); echo Profiler::getHtmlReportContent(); include 'static/bottom.php';