/*  VAX C-Prolog Benchmark Package  /*
/*  Copyright 1985 by Tektronix, Inc., and Portland State University  /*


/*  Get an average cpu time for 5 different parameters  */

test_hanoi :-
nl, write('!**  BEGIN Hanoi BENCHMARK'), nl,
ave_hanoi(2),
ave_hanoi(4),
ave_hanoi(6),
ave_hanoi(8),
ave_hanoi(10),
nl, write('!**  END Hanoi BENCHMARK'), nl.

/*  call the benchmark 3 times and calculate the average  */

ave_hanoi(P) :-
call_hanoi(P,T1),
call_hanoi(P,T2),
call_hanoi(P,T3),
calc_ave_hanoi(P,T1,T2,T3).

/*  call benchmark and return cputime in msecs.  */

call_hanoi(P,T) :-
T1 is cputime,
hanoi(P),
T2 is cputime,
T is 1000*(T2-T1).

/*  calculate average of 3 times for parameter P  */

calc_ave_hanoi(P,T1,T2,T3) :-
Ave is (T1+T2+T3)/3,
nl, write('!**  Average cputime for '),
write(P), write(' hanoi is '),
write(Ave), write(' msecs.'), nl.

:- test_hanoi.

