-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
May I create a Template instance first and the use it to render context? #4
Comments
In my test running at macbook pro I5 2.6G, python code runs in 0.9s, and java 2.5s. |
You can create a parsed representation of a template using the interpreter instance, as follows:
This actually runs in 1/3 of the time of your other java example, which is promising! 😄 I'm going to create a nicer factory method of getting a new interpreter instance from a Jinjava object. |
Results of updated benchmark code with precompiled (e6dbd9d):
|
Yes, it is much faster than before~ |
before I could create Node , I need a interpreter , but context of the interpreter varies every time, so use below method is better: TokenParser t = new TokenParser(null,template);
Node parsedTemplate =TreeParser.parseTree(t);
String s = interpreter.render(parsedTemplate); |
Now {{ theString[1:4] }} will render as a substring.
In http://product.hubspot.com/blog/jinjava-a-jinja-for-your-java the author says speed of jinja2 in python is 1387.3108 runs/s which is a bit slower than jinjava.
But I compared the 2 projects:
jinja2 is much faster if a Template is prepared in advance.
python code:
jinjava code:
I really hope i use jinjava in a wrong way. Is there any method I could first create a Template instance like jinja2?
The text was updated successfully, but these errors were encountered: