Debian Codegraph @

benchmark/profile.py

raw
1 """
2 JinjaX Benchmark
3 Copyright (c) Juan-Pablo Scaletti <[email protected]>
4 """
5 from pathlib import Path
6
7 from jinjax import Catalog, Component
8 from line_profiler import LineProfiler
9
10
11 HERE = Path(__file__).parent
12
13 catalog = Catalog()
14 catalog.add_folder(HERE)
15
16 profile = LineProfiler(
17 Catalog.irender,
18 Catalog._get_from_file,
19 Component.__init__,
20 Component.from_cache,
21 Component.filter_args,
22 Component.render,
23 )
24
25 def render_jinjax():
26 for _ in range(1000):
27 catalog.render("Hello", message="Hey there")
28
29
30 if __name__ == "__main__":
31 print("Profiling...")
32 profile.runcall(render_jinjax)
33 profile.print_stats()