Comparing Two Versions Of Code

Caporegime
Joined
14 Jan 2005
Posts
60,712
Location
Aberdeenshire
For a section of my thesis I have to compare two versions of code I have written. The code is in essence code for a line follower.

However, I want to compare the efficiency of the code. However it would be nigh-on impossible to replicate the starting position of the robot on the line each time.

Fellow Programmers, I need your help
 

Una

Una

Associate
Joined
26 Nov 2004
Posts
2,471
Location
Reading / Lake District
There is no easy way to compare code really. You could try to profile it or you can work out what big O notation your algorithms follow. You could also disassemble it and work out the number of machine intructions needed to perform the operation (Hehe). You could just time them I guess as well (Depends how mathmatically sound you want your results).
 
Last edited:
Associate
Joined
26 Oct 2002
Posts
1,714
Why not write a test framework that feeds data to your program, and then simply time how long each program takes to complete a data run?

Can be a bit of a pain but you can feed them different size data sets, and use that to show efficiency improvements that one piece of code gives over another?
 
Soldato
Joined
9 May 2005
Posts
4,528
Location
Nottingham
What language is it in?

In java you can write a test framework and use a time to calculate the speed of different operations. I had to compare an ArrayList to a LinkedList before to see which was more efficient for the situation and I use this method. It works quite well but it depends what your language has to offer.
 
Back
Top Bottom