summaryrefslogtreecommitdiff
path: root/examples/profile.py
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-01-10 12:58:38 -0800
committerDavid Lord <davidism@gmail.com>2020-01-10 12:58:38 -0800
commite492255f270add52d051ef4f8e87899f40e57687 (patch)
tree5c32f9e526b2efae6d901bc4dd77655dbf8ab3b5 /examples/profile.py
parent143667d95d73730415bb1281d1cd5e439b366fec (diff)
downloadjinja2-e492255f270add52d051ef4f8e87899f40e57687.tar.gz
remove old scripts and examples
Diffstat (limited to 'examples/profile.py')
-rw-r--r--examples/profile.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/examples/profile.py b/examples/profile.py
deleted file mode 100644
index b16d99f..0000000
--- a/examples/profile.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import print_function
-
-try:
- from cProfile import Profile
-except ImportError:
- from profile import Profile
-from pstats import Stats
-from jinja2 import Environment as JinjaEnvironment
-
-context = {
- "page_title": "mitsuhiko's benchmark",
- "table": [
- dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10) for x in range(1000)
- ],
-}
-
-source = """\
-% macro testmacro(x)
- <span>${x}</span>
-% endmacro
-<!doctype html>
-<html>
- <head>
- <title>${page_title|e}</title>
- </head>
- <body>
- <div class="header">
- <h1>${page_title|e}</h1>
- </div>
- <div class="table">
- <table>
- % for row in table
- <tr>
- % for cell in row
- <td>${testmacro(cell)}</td>
- % endfor
- </tr>
- % endfor
- </table>
- </div>
- </body>
-</html>\
-"""
-jinja_template = JinjaEnvironment(
- line_statement_prefix="%", variable_start_string="${", variable_end_string="}"
-).from_string(source)
-print(jinja_template.environment.compile(source, raw=True))
-
-
-p = Profile()
-p.runcall(lambda: jinja_template.render(context))
-stats = Stats(p)
-stats.sort_stats("time", "calls")
-stats.print_stats()