]> git.za3k.com Git - blog.git/commitdiff
3x faster (22s->6s)
authorZachary Vance <za3k@za3k.com>
Fri, 28 Feb 2025 21:10:02 +0000 (16:10 -0500)
committerZachary Vance <za3k@za3k.com>
Sun, 6 Apr 2025 00:36:02 +0000 (20:36 -0400)
before.txt
blog

index baa7697f068ee9337bcae20dca9308cdff004a1a..b4ade24fd2782c3dd94849bb17c79cba7f77d57a 100644 (file)
@@ -1,24 +1,23 @@
     load configs (3ms)
-        load one post (x252, 0ms/ea, 225ms total)
-      load one post (228ms)
+        load one post (x252, 0ms/ea, 222ms total)
+      load one post (225ms)
       sort (0ms)
-    load posts (228ms)
-  load phase (232ms)
-  clean phase (57ms)
+    load posts (225ms)
+  load phase (229ms)
+  clean phase (60ms)
       image (x83, 0ms/ea, 50ms total)
     image (52ms)
-      static (x1065, 0ms/ea, 323ms total)
-    static (339ms)
-      post (x252, 13ms/ea, 3436ms total)
-    post (3438ms)
-      tag (x294, 33ms/ea, 9938ms total)
-    tag (9941ms)
-      category (x4, 732ms/ea, 2931ms total)
-    category (2931ms)
-      author (x1, 2298ms/ea, 2298ms total)
-    author (2299ms)
-      page (x2, 1399ms/ea, 2798ms total)
-    page (2798ms)
-  generate phase (21801ms)
-overall (22091ms)
-
+      static (x1065, 0ms/ea, 328ms total)
+    static (345ms)
+      post (x252, 8ms/ea, 2194ms total)
+    post (2197ms)
+      tag (x294, 7ms/ea, 2087ms total)
+    tag (2089ms)
+      category (x4, 104ms/ea, 418ms total)
+    category (418ms)
+      author (x1, 115ms/ea, 115ms total)
+    author (115ms)
+      page (x2, 166ms/ea, 332ms total)
+    page (332ms)
+  generate phase (5551ms)
+overall (5841ms)
diff --git a/blog b/blog
index 79245f5df52dd00f08188eed90cbb8ac59fb5e46..f83fb6c838a470726cadea06b9ce9b166747999c 100755 (executable)
--- a/blog
+++ b/blog
@@ -31,6 +31,7 @@ import time
 import yaml
 import zoneinfo
 from markdown2html import markdown2html
+from functools import cache, cached_property
 
 from pathlib import Path
 
@@ -265,7 +266,7 @@ class Post(Templatable):
 
     # TODO: Add an 'above the fold' part, maybe
 
-    @property
+    @cached_property
     def post(self):
         return '<div class="entry-content">{}</div>'.format(markdown2html(self.md))
 
@@ -322,6 +323,7 @@ class Post(Templatable):
     def is_draft(self):
         return hasattr(self, "status") and self.status == "draft"
 
+    @cache
     def content(self):
         c = super().content()
         if self.blog.local: