comparing time of algorithms
I'm trying to implement the DFS and BFS algorithm and compare the time each one require to find the solution in a maze.
what I did is the following:
at the beginning of each algorithm
long start = System.currentTimeMillis();
and at the end:
long elapsed = System.currentTimeMillis() - start;
but the problem is that for the same algorithm in the same maze I get different number each time.
what should I do to get the time (or cpu time) which each algorithm require to solve a maze.