为什么StringTemplate会变慢? [英] Why StringTemplate could be slow?

查看:166
本文介绍了为什么StringTemplate会变慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用StringTemplate作为我的Web应用程序的视图层。最近我测量了渲染页面所花费的时间,简单页面大约为50ms,复杂页面大约为500ms。这对我的需求来说太多了,所以我正在寻找一种提高ST性能的方法。我该怎么做?

I'm using StringTemplate as view layer for my web application. Recently I've measured how much time is spent rendering pages and it's around 50ms for simple pages and 500ms for complex pages. This is too much for my needs, so I'm looking for a way to improve ST's performance. How can I do this?

StringTemplate.toString方法消耗了大部分时间,因此它不是缓存问题。

Most of the time is consumed by the StringTemplate.toString method, so it's not a cache problem.

我主动使用匿名模板和包含的模板 - 这可能是原因吗?

I actively use anonymous templates and included templates - could this be the cause?

推荐答案

使用write()不要toString然后写入你的流。 write()将呈现并传输无缓冲。很大的区别。
Ter

use write() not toString then writing to your stream. write() will render and transmit w/o buffering. big difference. Ter

这篇关于为什么StringTemplate会变慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆