home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum7.lzh
/
RICO
/
S_PROLOG
/
PROG
/
newlips.pl
< prev
next >
Wrap
Text File
|
1988-09-26
|
995b
|
40 lines
/* Use bench(N) to calculate LIPS performance */
/* Install cputime(X) */
?- channel(cputime,6).
nrev([],[]).
nrev([X|Rest],Ans) :- nrev(Rest,L), my_append(L,[X],Ans).
my_append([],L,L).
my_append([X|L1],L2,[X|L3]) :- my_append(L1,L2,L3).
bench(Count) :- cputime(T0),dodummy(Count),cputime(T1),
dobench(Count),cputime(T2),
report(Count,T0,T1,T2).
dobench(Count) :- data(List),my_repeat(Count),nrev(List,_),fail.
dobench(_).
dodummy(Count) :- data(List),my_repeat(Count),dummy(List,_),fail.
dodummy(_).
dummy(_,_).
data(X) :- data(X,30).
data([],0).
data([a|Y],N) :- N > 0, N1 is N - 1, data(Y,N1).
/* 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]). */
my_repeat(N).
my_repeat(N) :- N > 1, N1 is N - 1, my_repeat(N1).
report(Count,T0,T1,T2) :- write(T0),nl,write(T1),nl,write(T2),nl,
Time1 is T1 - T0,write(Time1),nl,
Time2 is T2 - T1,write(Time2),nl,
Time is Time2 - Time1,write(Time),nl,
Lips is (496 * Count)/Time,
write('Lips = '),write(Lips), nl.