diff --git a/src/Database.php b/src/Database.php
index d4e5ff7..c5a71e8 100644
--- a/src/Database.php
+++ b/src/Database.php
@@ -311,22 +311,6 @@ class Database extends Object
// Checks if the query is blank
if ($sql != '')
{
- // Builds out stack trace for queries
- $files = [];
-
- $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- krsort($backtrace);
-
- foreach ($backtrace as $file)
- {
- if (isset($file['class'], $file['line']))
- {
- $files[] = $file['class'] . ':' . $file['line'];
- }
- }
-
- $sql .= "\n" . '/* [' . implode('|', $files) . '] */';
-
// Establishes if we're working on an EXPLAIN
if ($this->config['pickles']['profiler'])
{
diff --git a/src/Profiler.php b/src/Profiler.php
index 9d76d0a..dc7b1fa 100644
--- a/src/Profiler.php
+++ b/src/Profiler.php
@@ -25,18 +25,13 @@ namespace Pickles;
* config.ini for a site. Out of the box the profiler will report on every
* class object in the system that extends the code Object class.
*
- * Note: I really wanted to use PHP Quick Profiler by Ryan Campbell of
- * Particletree but it kept barking out errors when I tried to use it with
- * E_STRICT turned on. Here's a link anyway since it looks awesome:
- * http://particletree.com/features/php-quick-profiler/
- *
* @usage Profiler::log('some action you want to track');
* @usage Profiler::log($object, 'methodName');
*/
class Profiler
{
/**
- * Profile
+ * Logs
*
* Array of logged events
*
@@ -44,18 +39,7 @@ class Profiler
* @access private
* @var array
*/
- private static $profile = [];
-
- /**
- * Queries
- *
- * Number of queries that have been logged
- *
- * @static
- * @access private
- * @var integer
- */
- private static $queries = 0;
+ private static $logs = [];
/**
* Timers
@@ -68,41 +52,6 @@ class Profiler
*/
private static $timers = [];
- /**
- * Enabled
- *
- * Checks if the profiler is set to boolean true or if the passed type is
- * specified in the profiler configuration value.
- *
- * @param array $type type(s) to check
- * @return boolean whether or not the type is enabled
- */
- public static function enabled(/* polymorphic */)
- {
- $config = Config::getInstance();
- $config = $config['pickles']['profiler'];
-
- // Checks if we're set to boolean true
- if ($config === true)
- {
- return true;
- }
- else
- {
- $types = func_get_args();
-
- foreach ($types as $type)
- {
- if (stripos($config, $type) !== false)
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
/**
* Log
*
@@ -125,21 +74,23 @@ class Profiler
switch ($data_type)
{
case 'array':
- $log = '
' . print_r($data, true) . ''; + $details = print_r($data, true); break; case 'object': - $log = '[' . get_parent_class($data) . '] ' - . '' . get_class($data) . '' - . ($method != '' ? '->' . $method . '()' : ''); + $details['class'] = get_class($data); - $data_type = '' . $data_type . ''; + if ($method != '') + { + $details['method'] = $method . '()'; + } + + $data_type = $data_type; break; case 'timer': - $log = $method; - - $data_type = '' . $data_type . ''; + $details = $method; + $data_type = $data_type; break; case 'string': @@ -149,16 +100,16 @@ class Profiler $data_type = $type; } - $log = $data; + $details = $data; break; } - self::$profile[] = [ - 'log' => $log, - 'type' => $data_type, - 'time' => $time, - 'elapsed' => $time - $_SERVER['REQUEST_TIME_FLOAT'], - 'memory' => memory_get_usage(), + self::$logs[] = [ + 'type' => $data_type, + 'timestamp' => $time, + 'elapsed_time' => $time - $_SERVER['REQUEST_TIME_FLOAT'], + 'memory_usage' => memory_get_usage(), + 'details' => $details, ]; } @@ -175,41 +126,39 @@ class Profiler */ public static function logQuery($query, $input_parameters = false, $explain = false, $duration = false) { - self::$queries++; - - $log = ''; + $log = []; + /* if ($input_parameters != 'false' && is_array($input_parameters)) { - $log .= '
- Console
- = $logs; ?>
- |
-
- Load Time
- = number_format($duration * 100, 3) . ' ms / ' . ini_get('max_execution_time'); ?>
- |
-
- Memory Usage
- = $peak_usage . ' / ' . ini_get('memory_limit'); ?>
- |
-
- Database
- = $queries; ?>
- |
-
- Includes
- = $files; ?>
- |
-
Console | -Memory | -Time | -|
---|---|---|---|
= $entry['type']; ?> | -= $entry['log']; ?> | -= self::formatSize($entry['memory']); ?> | -= number_format($entry['elapsed'] * 100, 3); ?> ms | -