]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Profiler.php
Merge pull request #9186 from annando/valid-posts
[friendica.git] / src / Util / Profiler.php
index 1a5cd99922c6c47da90db8777a5d000c4f6ba76e..db3e1bb97825f38f4d48cab62170377e54dc4f6b 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Util;
 
 use Friendica\Core\Config\Cache;
 use Friendica\Core\Config\IConfig;
+use Friendica\Core\System;
 use Psr\Container\ContainerExceptionInterface;
 use Psr\Container\ContainerInterface;
 use Psr\Container\NotFoundExceptionInterface;
@@ -88,9 +89,9 @@ class Profiler implements ContainerInterface
         * Saves a timestamp for a value - f.e. a call
         * Necessary for profiling Friendica
         *
-        * @param int $timestamp the Timestamp
-        * @param string $value A value to profile
-        * @param string $callstack The callstack of the current profiling data
+        * @param int    $timestamp the Timestamp
+        * @param string $value     A value to profile
+        * @param string $callstack A callstack string, generated if absent
         */
        public function saveTimestamp($timestamp, $value, $callstack = '')
        {
@@ -98,6 +99,8 @@ class Profiler implements ContainerInterface
                        return;
                }
 
+               $callstack = $callstack ?: System::callstack(4, 1);
+
                $duration = floatval(microtime(true) - $timestamp);
 
                if (!isset($this->performance[$value])) {
@@ -177,7 +180,7 @@ class Profiler implements ContainerInterface
                        $output .= "\nDatabase Read:\n";
                        foreach ($this->callstack["database"] as $func => $time) {
                                $time = round($time, 3);
-                               if ($time > 0.001) {
+                               if ($time > 0) {
                                        $output .= $func . ": " . $time . "\n";
                                }
                        }