]> git.mxchange.org Git - friendica.git/commitdiff
Add cache performance to API and worker
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 1 Mar 2018 06:25:39 +0000 (01:25 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 5 Mar 2018 04:13:19 +0000 (23:13 -0500)
include/api.php
src/Core/Worker.php

index f742d2cb2abd3b1a8ee31c2ce59e4353d852ea23..60a9acce0dbd6c1e84eb9170e477290572ae66dd 100644 (file)
@@ -317,12 +317,16 @@ function api_call(App $a)
                                        /// @TODO round() really everywhere?
                                        logger(
                                                parse_url($a->query_string, PHP_URL_PATH) . ": " . sprintf(
-                                                       "Database: %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
+                                                       "Database: %s/%s, Cache %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
                                                        round($a->performance["database"] - $a->performance["database_write"], 3),
                                                        round($a->performance["database_write"], 3),
+                                                       round($a->performance["cache"], 3),
+                                                       round($a->performance["cache_write"], 3),
                                                        round($a->performance["network"], 2),
                                                        round($a->performance["file"], 2),
-                                                       round($duration - ($a->performance["database"] + $a->performance["network"]     + $a->performance["file"]), 2),
+                                                       round($duration - ($a->performance["database"]
+                                                               + $a->performance["cache"] + $a->performance["cache_write"]
+                                                               + $a->performance["network"] + $a->performance["file"]), 2),
                                                        round($duration, 2)
                                                ),
                                                LOGGER_DEBUG
@@ -344,6 +348,21 @@ function api_call(App $a)
                                                        }
                                                }
 
+                                               $o = "Cache Read:\n";
+                                               foreach ($a->callstack["cache"] as $func => $time) {
+                                                       $time = round($time, 3);
+                                                       if ($time > 0) {
+                                                               $o .= $func . ": " . $time . "\n";
+                                                       }
+                                               }
+                                               $o .= "\nCache Write:\n";
+                                               foreach ($a->callstack["cache_write"] as $func => $time) {
+                                                       $time = round($time, 3);
+                                                       if ($time > 0) {
+                                                               $o .= $func . ": " . $time . "\n";
+                                                       }
+                                               }
+
                                                $o .= "\nNetwork:\n";
                                                foreach ($a->callstack["network"] as $func => $time) {
                                                        $time = round($time, 3);
index f5979a82ab9f4c697a91e0990fdc6b4a3022136b..525287dd0d605488bccdb9aa747da04f4bbdf326 100644 (file)
@@ -325,6 +325,8 @@ class Worker
                        $a->performance["start"] = microtime(true);
                        $a->performance["database"] = 0;
                        $a->performance["database_write"] = 0;
+                       $a->performance["cache"] = 0;
+                       $a->performance["cache_write"] = 0;
                        $a->performance["network"] = 0;
                        $a->performance["file"] = 0;
                        $a->performance["rendering"] = 0;
@@ -409,6 +411,24 @@ class Worker
                                                }
                                        }
                                }
+                               if (isset($a->callstack["dache"])) {
+                                       $o .= "\nCache Read:\n";
+                                       foreach ($a->callstack["dache"] as $func => $time) {
+                                               $time = round($time, 3);
+                                               if ($time > 0) {
+                                                       $o .= $func.": ".$time."\n";
+                                               }
+                                       }
+                               }
+                               if (isset($a->callstack["dache_write"])) {
+                                       $o .= "\nCache Write:\n";
+                                       foreach ($a->callstack["dache_write"] as $func => $time) {
+                                               $time = round($time, 3);
+                                               if ($time > 0) {
+                                                       $o .= $func.": ".$time."\n";
+                                               }
+                                       }
+                               }
                                if (isset($a->callstack["network"])) {
                                        $o .= "\nNetwork:\n";
                                        foreach ($a->callstack["network"] as $func => $time) {
@@ -422,12 +442,16 @@ class Worker
 
                        logger(
                                "ID ".$queue["id"].": ".$funcname.": ".sprintf(
-                                       "DB: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
+                                       "DB: %s/%s, Cache: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
                                        number_format($a->performance["database"] - $a->performance["database_write"], 2),
                                        number_format($a->performance["database_write"], 2),
+                                       number_format($a->performance["cache"], 2),
+                                       number_format($a->performance["cache_write"], 2),
                                        number_format($a->performance["network"], 2),
                                        number_format($a->performance["file"], 2),
-                                       number_format($duration - ($a->performance["database"] + $a->performance["network"] + $a->performance["file"]), 2),
+                                       number_format($duration - ($a->performance["database"]
+                                               + $a->performance["cache"] + $a->performance["cache_write"]
+                                               + $a->performance["network"] + $a->performance["file"]), 2),
                                        number_format($duration, 2)
                                ),
                                LOGGER_DEBUG