【发布时间】:2012-02-01 14:30:50
【问题描述】:
我们正在研究 grails 应用程序的性能,似乎 grails 需要很多时间(7-13 毫秒)才能从服务中恢复到控制器。返回的数据是对域对象的引用(带有 2 个引用的映射),不是很复杂。有什么办法可以缩短这个时间?
我们在服务中的 return 语句之前有 log.debug(),在离开服务之后,在控制器中还有一个。
2012-02-01 15:16:07,048 [http-8080-1] DEBUG api.TestService test before service return
2012-02-01 15:16:07,063 [http-8080-1] DEBUG api.TestController test after service return
编辑:Grails 1.3.7 版
编辑:开启休眠 SQL 日志记录后:
2012-02-02 09:20:04,504 [http-localhost%2F127.0.0.1-8080-1] DEBUG api.TestService before return
2012-02-02 09:20:04,505 [http-localhost%2F127.0.0.1-8080-1] DEBUG hibernate.SQL select nextval ('hibernate_sequence')
2012-02-02 09:20:04,516 [http-localhost%2F127.0.0.1-8080-1] DEBUG hibernate.SQL insert into test ...
2012-02-02 09:20:04,520 [http-localhost%2F127.0.0.1-8080-1] DEBUG hibernate.SQL update test1 ...
2012-02-02 09:20:04,522 [http-localhost%2F127.0.0.1-8080-1] DEBUG hibernate.SQL insert into test_test1 ...
2012-02-02 09:20:04,524 [http-localhost%2F127.0.0.1-8080-1] DEBUG api.TestController after service
【问题讨论】:
-
您是否尝试过使用调试器单步执行代码,深入 grails 的内部,看看它的去向?
-
你能提供一些信息吗?你在服务中做什么?地图有多少元素?代码 sn-ps?
-
认真的吗?您担心 7 到 13 毫秒?
-
哇!需要 60 毫秒的 api 中的 7 到 13 毫秒是时间的 1/5! 100 个请求浪费了 10 毫秒等于浪费了一秒 :)
-
主题:地图的内容重要吗?它应该是引用传递而不是对象本身。
标签: performance spring grails spring-mvc