简体   繁体   English

在Java中==和>或<操作之间是否存在性能差异?

[英]Is there a performance difference between == and > or < operations in java specifically

Is there a performance difference between == and > / < operations in java specifically. 专门在Java中==> / <操作之间是否存在性能差异。

I have already read this answer , but it doesn't say in terms of java nor the comparison is in between similar operands. 我已经读过这个答案 ,但是它没有用java来表示,也没有在相似的操作数之间进行比较。

As multiple answers already stated , the operators (and all instructions) are converted to machine-understable language (usually, Assembly or Byte code work as a middle: your code is translated to those, then to binary. However, I'm not really working at/used to this level of programming. Feel free to correct me if I'm missing some point / machine language.) 由于多个 答案已经表示 ,运营商(和所有指令)转换为机器语言understable(通常是大会字节代码工作作为中间:你的代码转换为那些,然后以二进制不过,我不是真的。在这种级别的编程下使用/使用过。如果我缺少某些点/机器语言,请随时纠正我。)

Java compiles its classes to Byte code, which is then translated to machine code (binary) to perform hardware operations and computations. Java将其类编译为字节码,然后将其转换为机器码(二进制)以执行硬件操作和计算。 You can even look the byte code by yourself , if it is really needed. 如果确实需要,您甚至可以自己查看字节码


Considering the operators themselves, practically any microprocessor nowadays is able to optimize and make this kind of operations nearly instantaneous. 考虑到操作员本身,当今几乎任何微处理器都能够优化并使这种操作几乎是即时的。 If there was any difference between == and > / < in terms of performance, it would be in the order of mere nanoseconds, being Java, C++ or any compiled language. 如果==> / <在性能方面存在任何差异,则它仅是纳秒级的数量,即Java,C ++或任何编译语言。 I am not even sure you could perform "in-code" metrics about this level of performance, considering Java, coupled with hardware, won't always be able to give you precise time measurement when it comes to nanoseconds. 我什至不确定您是否可以执行有关此性能级别的“代码内”度量,因为考虑到Java与硬件结合使用, 将无法始终为您提供精确的纳秒级时间测量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在jsp中编写java之间有性能差异吗? - Is there a performance difference between writing java inside jsp? 测量 Python 和 Java 实现之间的性能差异? - Measuring performance difference between Python and Java implementations? Serializable和Externalizable(Java)之间的性能差异 - Performance difference between Serializable and Externalizable (Java) 在Java中,新旧本地之间是否存在性能差异? - In Java, is there a performance difference between new and local? Java中ArrayList和LinkedList之间的区别 - 性能的原因 - Difference between ArrayList and LinkedList in Java - the whys for performance “静态”是什么意思以及它在不同语言(特别是 C 和 Java)之间的区别 - what does "static" mean and the difference of it between different languages(specifically C and Java) 捕获异常或某些类型异常之间是否有任何性能差异? - Java - Is there any performance difference between catching Exception or certain type exception ? - Java 在 Java 中使用 int a=a+1 和 a++ 之间的性能差异 - Performance difference between using int a=a+1 and a++ in Java Java 6和7之间有什么区别会导致性能问题? - What is the difference between Java 6 and 7 that would cause a performance issue? Java中if(!foo)和if(foo == false)之间的性能差异(如果有)是什么? - What is the performance difference, if any, between if(!foo) and if(foo == false) in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM