home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd3.lzh / SBPROLOG2.2 / PROG / BENCHMARKS / newlips.P < prev    next >
Text File  |  1991-08-10  |  883b  |  36 lines

  1. newlips :- true.
  2.  
  3. nrev([],[]).
  4. nrev([X|Rest],Ans) :- nrev(Rest,L), append(L,[X],Ans).
  5.  
  6. append([],L,L).
  7. append([X|L1],L2,[X|L3]) :- append(L1,L2,L3).
  8.  
  9. bench(Count) :- cputime(T0),dodummy(Count),cputime(T1),
  10.     dobench(Count),cputime(T2),
  11.     report(Count,T0,T1,T2).
  12.  
  13. dobench(Count) :- data(List),repeat(Count),nrev(List,_),fail.
  14. dobench(_).
  15.  
  16. dodummy(Count) :- data(List),repeat(Count),dummy(List,_),fail.
  17. dodummy(_).
  18.  
  19. dummy(_,_).
  20.  
  21. data(X) :- data(X,30).
  22. data([],0).
  23. data([a|Y],N) :- N > 0, N1 is N-1, data(Y,N1).
  24. /* data([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd]). */
  25.  
  26. repeat(N).
  27. repeat(N) :- N > 1, N1 is N-1, repeat(N1).
  28.  
  29. report(Count,T0,T1,T2) :- write(T0),nl,write(T1),nl,write(T2),nl,
  30.     Time1 is T1 - T0,write(Time1),nl,
  31.     Time2 is T2 - T1,write(Time2),nl,
  32.     Time is Time2-Time1,write(Time),nl,
  33.     Lips is (496*Count*1000)/Time,
  34.     write('Lips = '),write(Lips), nl.
  35.  
  36.