Created
November 6, 2014 00:09
-
-
Save bootandy/432315fa690c7c1b5c35 to your computer and use it in GitHub Desktop.
How 2 line_profiler test a jinja2 template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from jinja2 import Environment, FileSystemLoader | |
from line_profiler import LineProfiler | |
@profile | |
def render_template(template_filename, context): | |
return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context) | |
PATH = os.path.dirname(os.path.abspath(__file__)) | |
TEMPLATE_ENVIRONMENT = Environment(loader=FileSystemLoader(os.path.join(PATH, ''))) | |
file = "out.jinja2" | |
context = {'urls': ['a.com']} | |
for i in range(0, 1000): | |
out = render_template(file, context) | |
#print(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment