• Post Reply Bookmark Topic Watch Topic
  • New Topic

cpu and memory usage  RSS feed

 
Jerry Olsson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm been developing quite alot for cell phones lately and have realised I'm not really take cpu and memory usage into consideration when I'm writing my code
I'm trying to improve my skills on this area and I have some questions.

What would be more efficient of the following:



I guess the difference is minimal but it made me wonder
Anyone have any idea about this one?
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Guess this is the same as this one

http://www.coderanch.com/t/202740/Performance/java/method-calls-vs-property
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If getClipWidth() returns a stored integer, the difference is indeed going to be quite small. If, on the other hand, it does any kind of computation, then of course caching the value in a variable will be faster than repeating the calculation.

As a rule, don't worry about optimizing something as trivial as this until you have a performance problem and need to fix it. Then do a lot of profiling!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!