From: Zachary Vance Date: Fri, 28 Feb 2025 21:10:02 +0000 (-0500) Subject: 3x faster (22s->6s) X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=ffd1fde235142eef286353ec5dd021a9f60d2283;p=blog.git 3x faster (22s->6s) --- diff --git a/before.txt b/before.txt index baa7697..b4ade24 100644 --- a/before.txt +++ b/before.txt @@ -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 79245f5..f83fb6c 100755 --- 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 '
{}
'.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: