aspose file tools*
The moose likes Cattle Drive and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark ""overhead" of inefficient code" Watch ""overhead" of inefficient code" New topic
Author

"overhead" of inefficient code

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Why do people say it costs more or increases overhead to have inefficient code?

Is it only because of CPU cycles? And really, when we're talking about less than a second, how bad is it, really, to do math or concatenate inside a loop?

What will it cost, a dollar every 1000000000 years?


When you do things right, people won't be sure you've done anything at all.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1362
    
  17
I've kind of always assumed that it's CPU cycles, but I've never asked. Interesting question!

In my book readability trumps everything - but if a more efficient way of doing things doesn't interfere with readability, I think making a habit of the more efficient way is just good practice.

On a small scale, it probably doesn't matter so much, but I bet LinkedIn and Twitter and Facebook probably don't want to be redoing the same calculation 20k times when they can do it once, stash the result in memory and just access that.

At my work we have been throwing hardware at inefficient code, which has turned out to be very expensive. Some of my colleagues spent a week getting chummy with the profiler, and reduced the - uh - overhead considerably... it was pretty dramatic, actually.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1665
    
  11

Katrina Owen wrote:At my work we have been throwing hardware at inefficient code.


Hmmm.... prolly need to buy more monitors. You should think about throwing less fragile things at physical things instead of logical ones.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1362
    
  17
But it's sooo satisfying!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Katrina Owen wrote:In my book readability trumps everything ...

Almost always when something becomes more readable, it also becomes more efficient. I think that making something more efficient does not necessarily mean it becomes less readable in the process. So either direction you come from should produce readable, easily maintainable code.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "overhead" of inefficient code