diff options
-rw-r--r-- | kohana/core/Benchmark.php | 36 | ||||
-rw-r--r-- | kohana/helpers/html.php | 2 | ||||
-rw-r--r-- | kohana/libraries/ORM.php | 3 | ||||
-rw-r--r-- | kohana/libraries/Profiler.php | 5 |
4 files changed, 29 insertions, 17 deletions
diff --git a/kohana/core/Benchmark.php b/kohana/core/Benchmark.php index 5a0111f5..876844f1 100644 --- a/kohana/core/Benchmark.php +++ b/kohana/core/Benchmark.php @@ -22,16 +22,18 @@ final class Benchmark { */ public static function start($name) { - if ( ! isset(self::$marks[$name])) - { - self::$marks[$name] = array + if ( ! isset(self::$marks[$name])) { + self::$marks[$name] = array(); + } + + array_unshift(self::$marks[$name], array ( - 'start' => microtime(TRUE), - 'stop' => FALSE, + 'start' => microtime(TRUE), + 'stop' => FALSE, 'memory_start' => function_exists('memory_get_usage') ? memory_get_usage() : 0, 'memory_stop' => FALSE - ); - } + ) + ); } /** @@ -42,10 +44,10 @@ final class Benchmark { */ public static function stop($name) { - if (isset(self::$marks[$name]) AND self::$marks[$name]['stop'] === FALSE) + if (isset(self::$marks[$name]) AND self::$marks[$name][0]['stop'] === FALSE) { - self::$marks[$name]['stop'] = microtime(TRUE); - self::$marks[$name]['memory_stop'] = function_exists('memory_get_usage') ? memory_get_usage() : 0; + self::$marks[$name][0]['stop'] = microtime(TRUE); + self::$marks[$name][0]['memory_stop'] = function_exists('memory_get_usage') ? memory_get_usage() : 0; } } @@ -76,7 +78,7 @@ final class Benchmark { if ( ! isset(self::$marks[$name])) return FALSE; - if (self::$marks[$name]['stop'] === FALSE) + if (self::$marks[$name][0]['stop'] === FALSE) { // Stop the benchmark to prevent mis-matched results self::stop($name); @@ -84,10 +86,18 @@ final class Benchmark { // Return a string version of the time between the start and stop points // Properly reading a float requires using number_format or sprintf + $time = $memory = 0; + for ($i = 0; $i < count(self::$marks[$name]); $i++) + { + $time += self::$marks[$name][$i]['stop'] - self::$marks[$name][$i]['start']; + $memory += self::$marks[$name][$i]['memory_stop'] - self::$marks[$name][$i]['memory_start']; + } + return array ( - 'time' => number_format(self::$marks[$name]['stop'] - self::$marks[$name]['start'], $decimals), - 'memory' => (self::$marks[$name]['memory_stop'] - self::$marks[$name]['memory_start']) + 'time' => number_format($time, $decimals), + 'memory' => $memory, + 'count' => count(self::$marks[$name]) ); } diff --git a/kohana/helpers/html.php b/kohana/helpers/html.php index 37f80ae3..daf16a04 100644 --- a/kohana/helpers/html.php +++ b/kohana/helpers/html.php @@ -116,7 +116,7 @@ class html_Core { * @param array HTML anchor attributes * @return string */ - public static function panchor($protocol, $uri, $title = FALSE, $attributes = FALSE) + public static function panchor($protocol, $uri, $title = NULL, $attributes = FALSE) { return html::anchor($uri, $title, $attributes, $protocol); } diff --git a/kohana/libraries/ORM.php b/kohana/libraries/ORM.php index fbbe9b92..1984b933 100644 --- a/kohana/libraries/ORM.php +++ b/kohana/libraries/ORM.php @@ -1285,7 +1285,8 @@ class ORM_Core { */ protected function load_type($column, $value) { - if (is_object($value) OR is_array($value) OR ! isset($this->table_columns[$column])) + $type = gettype($value); + if ($type == 'object' OR $type == 'array' OR ! isset($this->table_columns[$column])) return $value; // Load column data diff --git a/kohana/libraries/Profiler.php b/kohana/libraries/Profiler.php index 9888baae..3c2a460d 100644 --- a/kohana/libraries/Profiler.php +++ b/kohana/libraries/Profiler.php @@ -133,7 +133,8 @@ class Profiler_Core { $table->add_column(); $table->add_column('kp-column kp-data'); $table->add_column('kp-column kp-data'); - $table->add_row(array('Benchmarks', 'Time', 'Memory'), 'kp-title', 'background-color: #FFE0E0'); + $table->add_column('kp-column kp-data'); + $table->add_row(array('Benchmarks', 'Time', 'Count', 'Memory'), 'kp-title', 'background-color: #FFE0E0'); $benchmarks = Benchmark::get(TRUE); @@ -146,7 +147,7 @@ class Profiler_Core { // Clean unique id from system benchmark names $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK.'_', '', $name))); - $data = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2).'MB'); + $data = array($name, number_format($benchmark['time'], 3), $benchmark['count'], number_format($benchmark['memory'] / 1024 / 1024, 2).'MB'); $class = text::alternate('', 'kp-altrow'); if ($name == 'Total Execution') |