Comments (5)
In my test running at macbook pro I5 2.6G, python code runs in 0.9s, and java 2.5s.
from jinjava.
You can create a parsed representation of a template using the interpreter instance, as follows:
JinjavaInterpreter interpreter = new JinjavaInterpreter(jinjava, jinjava.getGlobalContext(), jinjava.getGlobalConfig());
Node parsedTemplate = interpreter.parse(template);
s = System.currentTimeMillis();
for (int i = 0; i < 70000; i++) {
interpreter.render(parsedTemplate, true);
}
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.
from jinjava.
Results of updated benchmark code with precompiled (e6dbd9d):
Result: 148.433 ±(99.9%) 2.078 ops/s [Average]
Statistics: (min, avg, max) = (77.945, 148.433, 158.897), stdev = 8.798
Confidence interval (99.9%): [146.355, 150.511]
# Run complete. Total time: 00:27:09
Benchmark Mode Samples Score Error Units
c.h.j.b.jinja2.Jinja2Benchmark.precompiledBenchmark thrpt 200 9951.372 ± 203.122 ops/s
c.h.j.b.jinja2.Jinja2Benchmark.realWorldishBenchmark thrpt 200 1160.294 ± 15.803 ops/s
c.h.j.b.liquid.LiquidBenchmark.parse thrpt 200 1657.029 ± 23.344 ops/s
c.h.j.b.liquid.LiquidBenchmark.parseAndRender thrpt 200 148.433 ± 2.078 ops/s
from jinjava.
Yes, it is much faster than before~
But our java version is 1.7 unfortunately, so i have to use jinjava 1.0.9. Maybe that is why is runs 1/2 of the time of previous example.
Thank you all very much!
from jinjava.
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);
from jinjava.
Related Issues (20)
- Can Dict key be an integer? HOT 2
- CVEs in current version: 2.7.0
- time for 2.7.1 / 2.8.0 ?
- Unexpected behavior comparing empty strings to 0
- Is the expression interpolation recursive? HOT 1
- Problem with using the function in nested interpretation HOT 2
- SnakeYAML 1.27 vulnerability in Jinjava 2.7.1 HOT 1
- Add {% hubl %} tag
- Maps in string representation in Сontext
- Support for "with" statement
- Resolve function with map like contructs HOT 1
- Mixing include and extends does not work
- Fix CVEs in version 2.7.1
- Inconsistent implementation with jinja2 HOT 1
- trouble with coercision in test
- Add support for java records HOT 1
- Rendering template with custom function in Scala throws NullPointerException HOT 4
- [question] receiving fixes flow // GHSA-h75v-3vvj-5mfj CVE-2024-34064 HOT 2
- upgrade commons-net to 3.10.0
- Fix eager execution handling of `{% print foo|render %}`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinjava.