Javac 调试打开和关闭之间是否存在性能差异? [英] Is there a performance difference between Javac debug on and off?

查看:25
本文介绍了Javac 调试打开和关闭之间是否存在性能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 Javac 打开调试信息的生成,那么类文件会大 20-25%.这对运行 Java 程序有任何性能影响吗?如果是,在哪些条件和多少条件下.我预计对加载类会有一点影响,因为文件较大,但这应该是最小的.

If I switch on the generating of debug info with Javac then the class files are 20-25% larger. Has this any performance effects on running the Java program? If yes on which conditions and how many. I expect a little impact on loading the classes because the files are larger but this should be minimal.

推荐答案

在任何语言中,调试信息都是元信息.它本质上会增加目标文件的大小,从而增加加载时间.在调试器外执行期间,此信息实际上被完全忽略.正如 JVM 规范中所述(虽然不明确) 调试信息存储在字节码流之外.这意味着在执行时,类文件没有区别.如果您想确定,请尝试一下:-).

In any language, debugging information is meta information. It by its nature increases the size of the object files, thus increasing load time. During execution outside a debugger, this information is actually completely ignored. As outlined (although not clearly) in the JVM spec the debug information is stored outside the bytecode stream. This means that at execution time there is no difference in the class file. If you want to be sure though, try it out :-).

附言.通常对于调试来说,关闭优化是有价值的.这确实会对性能产生影响.

Ps. Often for debugging there is value in turning off optimization. That does have a performance impact.

这篇关于Javac 调试打开和关闭之间是否存在性能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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