有没有人通过在GAE/ App引擎中使用更快的模板引擎获得了实际的收益?

时间:2022-05-26 04:43:27

I'm very tempted by pyTenjin's performance - http://www.kuwata-lab.com/tenjin/ It definitely beats the shit out of other templating engines - mako, jinja2, etc. But at the same time comes with the cost of learning a bit ugly templating system. Personally I love jinja2 / django style templates.

我对pyTenjin的表现很感兴趣——http://www.kuwata-lab.com/tenjin/它绝对胜过其他模板引擎——mako, jinja2等等。我个人喜欢jinja2 / django样式模板。

I like the idea that pyTenjin can bring down CPU usage to some extent - http://www.kuwata-lab.com/tenjin/pytenjin-faq.html#faq-google-appengine

我喜欢pyTenjin能够在一定程度上降低CPU使用率的想法——http://www.kuwata-lab.com/tenjin/pytenjin-faq.html#faq-google-appengine

I'm considering pyTenjin to either a) build views to be served in iframes on my customers' websites or b) to use it to generate dynamic javascripts based on configurations

我正在考虑使用pyTenjin来实现a)在我的客户网站上的iframe中生成视图,b)使用它生成基于配置的动态javascript

Performance seems to be a good plus point. On the minus, we have a little bit of time to learn pyTenjin and a bit of ugliness compromise. I could stick with jinja2 and divert focus on speed of development rather than that of ops/s

性能似乎是一个很好的优点。在缺点上,我们有一点时间学习pyTenjin和一些丑陋的妥协。我可以坚持使用jinja2,将注意力转移到开发速度上,而不是ops/s

But I wonder if the CPU usage reduction is significant at all. With not many heavily loaded app engine examples around me, I have to ask, has anyone experienced any gains in terms of CPU usage by changing their templating system so far?

但是我想知道CPU使用量的减少是否有意义。我不得不问,在我身边并没有太多加载严重的应用程序引擎示例的情况下,到目前为止,有没有人通过更改模板系统而在CPU使用率方面获得过什么好处?

1 个解决方案

#1


1  

Mako is pretty fast. But Jinja2 can be as fast if you use compiled templates. They are compiled to Python code and there's a loader to use them.

尖吻鲭鲨非常快。但是如果使用编译模板,Jinja2也可以同样快速。它们被编译成Python代码,有一个加载程序来使用它们。

I recommend you to make a conditional to use compiled templates in production and normal rendering while developing. Also, set auto_reload=False when instantiating the Environment in production, because your templates never change in production. And of course, cache rendered output when you can.

我建议您在开发过程中使用已编译的模板进行生产和正常呈现。另外,在实例化生产环境时,设置auto_reload=False,因为您的模板在生产环境中不会改变。当然,如果可以的话,缓存已呈现的输出。

Unless you're rendering huge templates, I don't see why you should spend your time moving to a different template system than the traditional Mako/Django/Jinja2.

除非您正在呈现巨大的模板,否则我不明白为什么您应该把时间花在与传统的Mako/Django/Jinja2不同的模板系统上。

#1


1  

Mako is pretty fast. But Jinja2 can be as fast if you use compiled templates. They are compiled to Python code and there's a loader to use them.

尖吻鲭鲨非常快。但是如果使用编译模板,Jinja2也可以同样快速。它们被编译成Python代码,有一个加载程序来使用它们。

I recommend you to make a conditional to use compiled templates in production and normal rendering while developing. Also, set auto_reload=False when instantiating the Environment in production, because your templates never change in production. And of course, cache rendered output when you can.

我建议您在开发过程中使用已编译的模板进行生产和正常呈现。另外,在实例化生产环境时,设置auto_reload=False,因为您的模板在生产环境中不会改变。当然,如果可以的话,缓存已呈现的输出。

Unless you're rendering huge templates, I don't see why you should spend your time moving to a different template system than the traditional Mako/Django/Jinja2.

除非您正在呈现巨大的模板,否则我不明白为什么您应该把时间花在与传统的Mako/Django/Jinja2不同的模板系统上。