且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java-性能问题;变量名和文件名长度

更新时间:2023-02-23 18:32:44

如果我使用带有短名称的变量会更好/更快地处理?

If i use variables with short names will be better/faster to process?

否.变量名称甚至可能不在您生成的字节码中.最终,变量将映射到寄存器/堆栈操作数.变量名称无关.它仅适用于人类.他们倾向于superPhrase而不是s.

No. Variable names might not even be in your resulting bytecode. In the end of the day variables are mapped to registers/stack operands. Variable name is irrelevant. It's only for human beings. And they tend to prefer superPhrase over s.

如果文件名短,则访问它会更快

if the file name is short will be faster to access it

.文件和变量一样,都是使用特殊标识符(例如inode)来引用的.仅在打开/定位文件时才需要文件名.与实际文件访问相比,它快了几个数量级.这同样适用于Java应用程序和其他OS进程.

No. Files, just like variables, are referenced using special identifiers (e.g. inodes). File name is only needed when opening/locating a file. And it's several orders of magnitude faster compared to actual file access. This applies equally to Java applications and other OS processes.