From 545d5f917d6f12a61d5156b486be58927038516e Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Tue, 1 Sep 2020 21:14:17 +0200 Subject: [PATCH] Count cache hits in black box output. --- av98.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/av98.py b/av98.py index 62d883e..02bfb68 100755 --- a/av98.py +++ b/av98.py @@ -288,6 +288,7 @@ class GeminiClient(cmd.Cmd): "refused_connections": 0, "reset_connections": 0, "timeouts": 0, + "cache_hits": 0, } self._connect_to_tofu_db() @@ -679,6 +680,7 @@ you'll be able to transparently follow links to Gopherspace!""") def _get_cached(self, url): mime, filename = self.cache[url] + self.log["cache_hits"] += 1 if mime.startswith("text/gemini"): with open(filename, "r") as fp: body = fp.read() @@ -1547,6 +1549,7 @@ current gemini browsing session.""" lines.append(("Timeouts:", self.log["timeouts"])) lines.append(("Refused connections:", self.log["refused_connections"])) lines.append(("Reset connections:", self.log["reset_connections"])) + lines.append(("Cache hits:", self.log["cache_hits"])) # Print for key, value in lines: print(key.ljust(24) + str(value).rjust(8))