
-----------------------------------
Geminias
Sat Aug 11, 2007 8:50 pm

Testing Efficiency?
-----------------------------------
What's the best way to compare efficiencies of different algorithms?  I tried the "time" command which I believe is the GNU/time(1) command built into bash but the results are staggered for multiple runs of the same program...  Also I don't know how to adjust the precision and frankly the documentation both in man and google sucks.

-----------------------------------
Ultrahex
Sat Aug 11, 2007 9:11 pm

Re: Testing Efficiency?
-----------------------------------
Testing multiple cases using the programming languages timer, or computer internal timer/clock cycles for the program. Also checking how many times it iterates through in the program is another way to check efficient such as big O notation.

-----------------------------------
Geminias
Sun Aug 12, 2007 6:23 am

RE:Testing Efficiency?
-----------------------------------
yeah cool but how?  (what program? whats the command?)

-----------------------------------
PaulButler
Sun Aug 12, 2007 6:16 pm

RE:Testing Efficiency?
-----------------------------------
I think Ultrahex is talking about programming the timer into the program, something like this:


// pseudocode
c = current time;
for (i = 0; i < 1000; i++)
     function_you_want_to_test(arguments, for, this_function);
avgtime = (current time - c) / 1000;

