Java-性能问题;变量名和文件名长度
关于性能的一些问题,但是我认为其中一些问题是合乎逻辑的: -如果我使用带短名称的变量会更好/更快地处理? 示例:"String s"将比"String superphrase"更好. -关于文件名,如果文件名短会更快地访问它? 例如:(几乎相同)filename.txt或f.txt.
Well just some questions about performance, but i think some of the questions are logical: - If i use variables with short names will be better/faster to process? Example: "String s", will be better than "String superphrase". - About the file names, if the file name is short will be faster to access it? Example: (almost the same) filename.txt or f.txt.
感谢大家,我真的很想让我的软件变得更好:)
Thanks to all guys, i really like to make my software as better as i can :)
如果我使用带有短名称的变量会更好/更快地处理?
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.