Java-性能问题;变量名和文件名长度 [英] Java - Performance Questions; variable names and file name length

查看:158
本文介绍了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.

这篇关于Java-性能问题;变量名和文件名长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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