Closed PerfectCarl closed 11 years ago
Assuming you have a folder named "plainjapid" in your application root and your template is:
"plainjapid/japidviews/my/view.html"
final String UNI = "universe";
JapidRenderer.init(OpMode.prod, "plainjapid", 1, null);
for (...) {
String r = JapidRenderer.renderWith("my.view", UNI);
System.out.println(r); }
I assumed you were testing against Japid and not Japid42, which is for integration with Play2.
2013/10/1 PerfectCarl notifications@github.com
See if that helps : https://github.com/branaway/Japid/blob/master/documentation/manual/Japid_Generic_Engine.textile
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-25393900 .
import cn.bran.japid.template;
import cn.bran.japid.compiler.OpMode;
2013/10/1 Bing Ran bing.ran@gmail.com
Assuming you have a folder named "plainjapid" in your application root and your template is:
"plainjapid/japidviews/my/view.html"
final String UNI = "universe";
JapidRenderer.init(OpMode.prod, "plainjapid", 1, null);
for (...) {
String r = JapidRenderer.renderWith("my.view", UNI);
System.out.println(r); }
I assumed you were testing against Japid and not Japid42, which is for integration with Play2.
2013/10/1 PerfectCarl notifications@github.com
See if that helps : https://github.com/branaway/Japid/blob/master/documentation/manual/Japid_Generic_Engine.textile
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-25393900 .
Thanks for your help, it is almost working. But I have an error :
[java] java.lang.IllegalArgumentException: wrong number of arguments
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at cn.bran.japid.util.RenderInvokerUtils.render(RenderInvokerUtils.java:26)
[java] at cn.bran.japid.template.JapidPlainController.invokeRender(JapidPlainController.java:76)
[java] at cn.bran.japid.template.JapidPlainController.getRenderResultWith(JapidPlainController.java:205)
[java] at cn.bran.japid.template.JapidPlainController.renderJapidWith(JapidPlainController.java:106)
[java] at cn.bran.japid.template.JapidRenderer.renderWith(JapidRenderer.java:729)
[java] at teb.Japid.renderToString(Japid.java:87)
[java] at teb.Japid.execute(Japid.java:64)
[java] at teb._BenchBase.run(_BenchBase.java:72)
[java] at teb.Japid.main(Japid.java:97)
Here's my code :
final String UNI = "universe";
JapidRenderer.init(OpMode.dev, "templates", 1, null);
output = JapidRenderer.renderWith(template, UNI);
And here's my template :
`args String test
TEST
By the way, it there any way to have a look at the generated classes ? Where are the generated source file generated ?
Okay, my bad. I was using the wrong template.
The generated Java classes are next to the Japid scripts.
Use prod mode when you do the benchmarking.
2013/10/1 PerfectCarl notifications@github.com
Okay, my bad. I was using the wrong template.
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-25456670 .
So I need to run the code once in dev mode to generate the file, and then in prod to do the benchmark. Is that right ?
It's not needed. It will get compiled when the Japid engine is initialized.
2013/10/1 PerfectCarl notifications@github.com
So I need to run the code once in dev mode to generate the file, and then in prod to do the benchmark. Is that right ?
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-25458110 .
When I use prod mode, I get this error :
[java] java.lang.RuntimeException: java.lang.ClassNotFoundException: japidviews.japid
[java] at cn.bran.japid.template.JapidPlainController.getRenderResultWith(JapidPlainController.java:197)
[java] at cn.bran.japid.template.JapidPlainController.renderJapidWith(JapidPlainController.java:106)
[java] at cn.bran.japid.template.JapidRenderer.renderWith(JapidRenderer.java:729)
[java] at teb.Japid.renderToString(Japid.java:85)
[java] at teb.Japid.execute(Japid.java:64)
[java] at teb._BenchBase.run(_BenchBase.java:72)
[java] at teb.Japid.main(Japid.java:94)
[java] Caused by: java.lang.ClassNotFoundException: japidviews.japid
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[java] at cn.bran.japid.template.JapidPlainController.getRenderResultWith(JapidPlainController.java:194)
[java] ... 6 more
Should my template be stored in different folder for production mode ?
When I get the produced string I get the following lines at start :
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
Is this because I am in dev mode ?
To disable the verbose output in dev mode:
cn.bran.japid.util.JapidFlags.verbose = false;
2013/10/1 PerfectCarl notifications@github.com
When I get the produced string I get the following lines at start :
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
[JapidRender]: All java files are up to date.
Is this because I am in dev mode ?
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-25460731 .
Hey,
I'm done with porting japid to the benchmark.
I still have issue with the production mode hint that you gave me.
That being said, would you be kind enough to have a look at my use of japid. Here's the java file invoking the engine and here's the template
Do you see any thing that can hinder the performance of japid ? The rendering is executed many times : maybe there is a way to keep the compiled template in memory (if that's not the case already).
I'll take a look at the prod issue in a bit.
The "open for" loop in the template comes with performance cost if you try to avoid any overhead.
Using generic for loop will help.
@int _index = 1; @boolean _isOdd = true; @for (Stock item: items) { ... ... @ _index++; _isOdd = !_isOdd; @}
The render class should have been cached already. So nothing to tweak there.
But there would be no performance if it runs in dev mode. Stay tuned for my diagnose.
2013/10/18 PerfectCarl notifications@github.com
Hey,
I'm done with porting japid to the benchmark.
I still have issue with the production mode hint that you gave me.
That being said, would you be kind enough to have a look at my use of japid. Here's the (java file) [ https://github.com/PerfectCarl/template-engine-benchmarks/blob/master/src/teb/Japid.java] invoking the engine and here's (the template) [ https://github.com/PerfectCarl/template-engine-benchmarks/blob/master/templates/japidviews/japid.html ]
Do you see any thing that can hinders the performance of japid ? The rendering is executed many times : maybe there is a way to keep the compiled template in memory if that's not the case already.
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-26538464 .
Thanks for reporting I actually have found an obvious bug. Please try version 0.9.31 to get the fix.
Great. Oh and, not that I expect it would be a surprise for you, but japid's performance are easily among the best. Le 18 oct. 2013 10:59, "branaway" notifications@github.com a écrit :
Thanks for reporting I actually have found an obvious bug. Please try version 0.9.31 to get the fix.
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-26580970 .
cool to know that.
bing ran, en route
在 2013年10月18日,17:10,PerfectCarl notifications@github.com 写道:
Great. Oh and, not that I expect it would be a surprise for you, but japid's performance are easily among the best. Le 18 oct. 2013 10:59, "branaway" notifications@github.com a écrit :
Thanks for reporting I actually have found an obvious bug. Please try version 0.9.31 to get the fix.
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-26580970 .
— Reply to this email directly or view it on GitHub.
It works great. Though, I have the following error
[Japid] [error] could not find the apply() with japid class: null
Is this a warning ?
The message was misleading. Fixed it in version 0.9.32 plus an important bug fix in tracking the source code of Japid classes. Please upgrade.
2013/10/18 PerfectCarl notifications@github.com
It works great. Though, I have the following error
[Japid] [error] could not find the apply() with japid class: null
Is this a warning ?
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-26588824 .
Will do. Thanks for your work. Le 19 oct. 2013 14:56, "branaway" notifications@github.com a écrit :
The message was misleading. Fixed it in version 0.9.32 plus an important bug fix in tracking the source code of Japid classes. Please upgrade.
2013/10/18 PerfectCarl notifications@github.com
It works great. Though, I have the following error
[Japid] [error] could not find the apply() with japid class: null
Is this a warning ?
— Reply to this email directly or view it on GitHub< https://github.com/branaway/Japid/issues/60#issuecomment-26588824> .
— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/60#issuecomment-26649190 .
I want to add japid to the template framework benchmark
So I need to code a simple class that would instanciate a japid template engine, give a collection of Item as an input parameter and execute the thing.
Here's an example of code for another template engine
Could you help me writing the code for japid ?