code review - The Cost of SQRT in C -


Do you determine what is the cycle cost for the given C library function?

Specifically, how expensive is it to call sqrt ()?

I should clarify here, I'm just looking for a general idea of ​​costs related to making some Library Functions calls. I believe that professional C programmers have the basic idea of ​​function cost for these things. For example, sqrt () may be deemed to show the performance down for O (n ^ 2).

First, you need to clearly define what you mean by "cycle cost" It can be interpreted as an algorithmic cycle or processor cycle.

First of all, theoretical.

If this is an algorithmic cycle, then I will make this determination through a code review

  • Get source code for that specific sqrt library implementation
  • Analysis of source code for assessing complexity
  • But as many others have posted, most instructions are set to use today, they will have a class instruction, so I I expect this source of C Implementation to call the country - Algorithm cycle is likely to be sustained.

    If this is the processor cycle, then you can make this determination in the same way, but some details will change:

    1. Determine the machine code that is processor 1, 2 and 3 will run and run
    2. I know more about the processor than
    3. It should be understood that it is useless and just test it ()

    For a test approach you want:

    1. Determine all the environment you
      1. Operator
      2. Operating system
    2. Author a test application
      1. You must complete all the tasks which you want to do out of sqrt
      2. It should display a certain number of iterations in the long term
      3. A single instruction and outgoing Should be drawn and a fixed number of long-term iterations It should be said, in fact,
      4. In fact, just think of it, identify why you want this information and how you will use it, and come up with a test app which probably removes many variables is.
      5. Run the application
        1. Run as close as the environment you care about
        2. If you use this information The final use will forecast performance for users - test in a representative environment while watching a netflix movie stream there are 10 different web browser windows running, test under those conditions)
      6. To analyze any kind of data Received set enable prediction.

    Comments