• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"overhead" of inefficient code

 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it's sooo satisfying!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic