Hardik Trivedi wrote:Hi All,
As subject lines says probably it may be really silly question for others but not for me.
The question is does length of name of variable affects performance or size of program ?
Hardik Trivedi wrote:What I want to know is whether it affects the time or not ?
And answer to this can be yes or no only....
Martin Vajsar wrote:
Hardik Trivedi wrote:What I want to know is whether it affects the time or not ?
And answer to this can be yes or no only....
Physically speaking, (measured with atomic clock ), yes.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hardik Trivedi wrote:
What I want to know is whether it affects the time or not ?
And answer to this can be yes or no only....
Jeff Verdegan wrote:
Hardik Trivedi wrote:
What I want to know is whether it affects the time or not ?
And answer to this can be yes or no only....
Not true. There could be other answers, such as "it depends."
Paul Clapham wrote:
Jeff Verdegan wrote:
Hardik Trivedi wrote:
What I want to know is whether it affects the time or not ?
And answer to this can be yes or no only....
Not true. There could be other answers, such as "it depends."
Or "who cares?", which is the answer already posted by several people in this thread. Here's another silly question: if I leave my front door open when I leave the house on my way to work, will I get to work faster? Yes or no?
fred rosenberger wrote:I don't think the answer is a clear cut 'yes' or 'no'. I have no idea how a hash might work, but it is CONCEIVABLY possible that all variable names need to be normalized to the same length to do the calculation. Perhaps the default is 20 bytes.
So, if you name a variable with only one character, the JVM has to allocate 20 bytes, copy the data over, pad the missing bytes, calculate the hash, then free the un-needed space.
Whereas if you named all your variables exactly 20 characters, all you have to do is calculate the hash.
So in this case, shorter variable names might SLOW DOWN things.
Yes, this is a silly example that is very contrived, but it is possible.
Hardik Trivedi wrote:So I will go with the Fred's answer that JVM keeps some predefined memory for all variable declaration.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:Depending on your system, nanoTime() may not be noticeably more accurate than currentTimeMillis() though.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here