Computer Science Canada

Testing Efficiency?

Author:  Geminias [ Sat Aug 11, 2007 8:50 pm ]
Post subject:  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.

Author:  Ultrahex [ Sat Aug 11, 2007 9:11 pm ]
Post subject:  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.

Author:  Geminias [ Sun Aug 12, 2007 6:23 am ]
Post subject:  RE:Testing Efficiency?

yeah cool but how? (what program? whats the command?)

Author:  PaulButler [ Sun Aug 12, 2007 6:16 pm ]
Post subject:  RE:Testing Efficiency?

I think Ultrahex is talking about programming the timer into the program, something like this:

code:

// pseudocode
c = current time;
for (i = 0; i < 1000; i++)
     function_you_want_to_test(arguments, for, this_function);
avgtime = (current time - c) / 1000;


: