Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: How to optimize CPU and Memory usage?

by CountZero (Bishop)
on Nov 24, 2013 at 14:13 UTC ( [id://1064118]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to optimize CPU and Memory usage?
in thread How to optimize CPU and Memory usage?

You are right about cars, but I do not see the analogy with computers.

What is the benefit of spending hours in optimizing and then shaving off 2 seconds and 100 MByte from a program that before optimization ran 5 seconds and used 250 MByte. Do you switch your computer on and off for each script you want to run?

That is what I mean with "premature" optimization.

My laptop is "on" the whole day I am in the office and the scripts I run really only use spare cycles and empty memory. How much power does a computer need to run an email client and an editor or a spreadsheet? If I can push CPU use above 25% with my "normal" work, I will have blisters on my fingers (and more typos than correctly typed words).

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics
  • Comment on Re^3: How to optimize CPU and Memory usage?

Replies are listed 'Best First'.
Re^4: How to optimize CPU and Memory usage?
by BrowserUk (Patriarch) on Nov 24, 2013 at 14:40 UTC
    What is the benefit of ... <ludicrously over stated straw man>

    How do you know that the OP is asking how to spend hours in order to save 2 seconds and 100 MB?

    Isn't it at least vaguely possible she has an application that is currently using all of her memory and she knows that it needs to grow?

    Could it be that that her application is currently taking hours or even days to run and that is simply to slow for the duty cycle she would like to be able to run?

    May be her application is a web-app that is gaining currency and clients, and whilst previously the fact that it used 1 GB of memory and took 30 or 40 seconds to return the results to the users was acceptable because it was only being used by a few people and no paying clients; the numbers now using it mean that each users copy is impacting every other concurrent users copy and slowing them all down.

    Maybe her choices are to spring for a substantially more expensive server/vm or to try and reduce the resources it uses so at to avoid that.

    Who says that it will "take hours" to optimise her application. There are a dozen or more instances of questions on this site where OP code has been speed up by orders of magnitude and/or had its memory footprint reduced by similar factors by one or a few simple changes to the way they were coded.

    The problem I have with your post is that it takes the minimal information provided -- basically the word "optimise" -- dreams up a moronic worst case scenario; applies an out-of-context, fatuous high-horse attitude and tries to score points by trotting out a party line truism of dubious benefit.

    Maybe all your programs run serially in 5 seconds and never tax your laptop; but some of us run serious code that requires serious amounts of resource; and that seriously benefit from being coded in a way that makes best use of those resources available.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Your argument goes both ways. Perhaps she has a small script that runs for 2 seconds. I don't know and you don't know, so why do you get all upset?

      What I said is based on solid ground: far too often I have seen that people spend too much time in optimizing things that run quite OK already. I spent lots of time optimizing programs when my computer had 16 kByte of RAM and allowed only 128 bytes of string storage and ran at a snail's pace. Yet I wrote arcadegames for it, in BASIC. But with 4GByte RAM and an 4 core i5 Intel CPU, I rarely find optimizations necessary for my purposes and it uses far less energy than my old rig.

      All I wanted to say is that optimization is not a goal in itself.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1064118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found