gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 09:36:01 31 4
gpt4 key购买 nike

根据 an article Groovy 有

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.

有人可以证明或反驳这些段落吗?

我特别关心多线程性能。

最佳答案

Groovy 的速度正在不断提高,但应该说 10 次中有 9 次,性能不是问题。

但是,如果这是一个问题,您可以或者用 Java 编写该代码(并将该 Java 类轻松集成到您的 Groovy 代码中),或者如果您想保持完全的 groovy,你可以考虑使用 Groovy++它通过使 Groovy 更加静态类型化来提高 Groovy 的速度(通过一些繁重的类型推断来避免你像 Java 一样必须自己做所有事情)

Groovy 1.8b4(目前处于测试阶段),也带有 GPars与它捆绑在一起的框架。

The GPars project offers developersnew intuitive and safe ways to handleJava or Groovy tasks concurrently,asynchronously, and distributed byutilizing the power of the Javaplatform and the flexibility of theGroovy language.

{编辑 2012 年 7 月}

Groovy 2.0 有一个 CompileStatic 注释,您可能需要研究一下(因为现在 Groovy++ 已经好几个月没有开发了)。 This question here有一些数字...

关于java - Groovy:与 Java 相比,多线程性能差,计算速度慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4912444/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com