Open mach-kernel opened 6 years ago
I think it's worth considering to not always create a new char
array that is just of the length of the required size, but to expand the capacity to a multiple of 2 (see implementation of StringBuilder
for details) and, therefore, save a lot of calls to System.arraycopy
. Especially, as append
gets invoked very often with shorter Strings. Further more I would suggest using a StringBuilder internally that handles all the low level details... 😃
please a pull request and will look.
thanks
I'm working on it in this branch, will make a PR when everything is ready + I want to write a test for the new char vector.
@mach-kernel did anything ever get pulled in? We're seeing slow speeds on partials as well, just wondering if there was a fix.
Hi, I have made an easy version using StringBuilder here: https://github.com/jknack/handlebars.java/pull/831 Needs a final test, but might help to move forward here.
I'm using this library as it is wrapped in vertx's templating adapters, source repo here. I have a very simple template (shown below) that just includes another partial (~27k in size) in order to render a header. I did a small benchmark using
ab -n1000 -c25 http://localhost:9090/
with one HTTP server instance using this library to render. Having to use the{{ > ... }}
is much slower than inlining it (~40 rps vs ~1k rps). I realize that caching mostly solves this issue but the discrepancy seems very large to me.I'm happy to explore solutions and go digging for how to optimize this. Thanks!
Template
Include Directive
No include directive
JProfiler