testing algorithm speeds

P

Paul

Hi group,
If I am trying to optimise an algorithm what options do I have for
logging the speed of a particular algorithm to compare against others?

In the past I have used system API functions to get nanoseconds but
I'm not sure this is very accurate.

Any ideas?
 
V

Victor Bazarov

Paul said:
If I am trying to optimise an algorithm what options do I have for
logging the speed of a particular algorithm to compare against others?

In the past I have used system API functions to get nanoseconds but
I'm not sure this is very accurate.

Any ideas?

There are products out there that are called "profilers" that should
help you collect the time data. You can write your own, of course.

There are plain "run of the mill", "brute force" approaches that let
you estimate the amount of time spent in your algorithm by running it
many times, thus giving you some kind of average timing.

There are indirect methods of estimating how your algorithm stacks up
agains other similar ones. Like counting the number of data copy
operations and arithmetic operations required.

Algorithm analysis also involves understanding how it behaves WRT
different data. E.g. some sorting algorithms behave better if data
are almost sorted, some do better if the data are pretty random to
begin with. I bet good books (like Knuth's TAOCP) talk about it.

I'd probably prioritise these in the order I mentioned them here. Do
what you feel gives you the most value: your time or money spent vs
the information you obtain. Each case is different, there is no true
common recipe that satisfies everybody.

Oh, and this topic is better discussed in comp.software-eng, BTW.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top