Satya Prasad <[EMAIL PROTECTED]> wrote: > Hi All, > In order to write efficient program, I was obsessed for better efficiency > code. I understood that for the same we need to have better design and > algorithms. And for measuring the algo efficiency I should calculate the time > spend by system. I use the concept of printing time before and end of the > algorithm execution. > > Is my concept correct or there is some other efficient method of measuring > an algorithm efficiency.
You are talking of two things: Efficient Code and Efficient Algo What you have done is profiling your function: measure time taken to execute your function. Typically you would do following for measuring your code optimization: (1) store time taken by function before you start optimization, (2) optimize your function, (3) profile how much time it takes after optimization. Subtract (3) and (1) is how much you've optimized your function\code. This has nothing do with your algo efficiency, though you can use same method for finding how improved your algo is. But you would be starting with O notation first, and use this as a measure to find how much more efficient your algo is. Hope that helps - Ananth
