groovy 慢,Groovy:与Java相比,多线程性能差和计算速度慢?

According to an article Groovy has

Unfortunately at the same time Groovy is very slow at runtime. As a person, who did a lot to improve performance of Groovy I can probably speak about that very openly. Groovy is very slow. You can easily expect that some Groovy calculation or data transformation rewritten in Java will become 3-5 times faster. Usually this factor is 8-12 and sometimes even higher. Someone can say that Java is always at our service and nobody uses Groovy for calculations or data processing... But, hey, it is exactly my point - why should we limit ourselves for just scripting or handling of simple web pages?

What is even worse is the fact that

Groovy doesn't scale well for

multi-core computers meaning that

several threads executing code

compiled by Groovy really prevent each

other from being fast. It is not a

problem for many applications but for

many others it is simply show-stopper.

Could someone proof or refute that paragraphs?

I am particularly concerned about multi threading performance.

解决方案

There are ongoing efforts to improve the speed of Groovy, but it should be said that 9 times in 10, the performance is not an issue.

However, where it is an issue you can either write that code in Java (and integrate that Java class easily into your Groovy code), or if you want to remain completely groovy, you can look into using Groovy++ which improves the speed of Groovy by making it more statically typed (with some heavy type inference to save you having to do it all yourself as with Java)

Groovy 1.8b4 (currently in beta), also comes with the GPars framework bundled with it.

The GPars project offers developers

new intuitive and safe ways to handle

Java or Groovy tasks concurrently,

asynchronously, and distributed by

utilizing the power of the Java

platform and the flexibility of the

Groovy language.

{edit July 2012}

Groovy 2.0 has a CompileStatic annotation which you may want to look into (as now Groovy++ has not been developed for quite a few months). This question here has some numbers...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值