Trailing-Edge
-
PDP-10 Archives
-
decuslib20-03
-
decus/20-0078/util/pretim.sim
There is 1 other file named pretim.sim in the archive. Click here to see a list.
!BEGIN
!!%Ext.Decl;
! EXTERNAL REAL PROCEDURE cptime;
! EXTERNAL PROCEDURE sigmean,scramble,exit;
! EXTERNAL TEXT PROCEDURE inline;
! INTEGER ncase_;
!
! Linesperpage(-1);
!!%Ncase;
!
!!%Prefix;
! BEGIN
! ARRAY s2_,m_,max_,min_,kvot_[1:ncase_];
! INTEGER ARRAY n_,k_,na_[1:ncase_];
! TEXT ARRAY case_name_[1:ncase_];
! REAL delta_t_,t_norm_,old_time_,new_time_,limit_,
! oldlimit_,top_,init_time_,t_alfa_;
! INTEGER case_,j_,j_n_,u_,kmin_,jmin_,bestcase_,
! nestbestcase_,n_scramble_;
! BOOLEAN test_flag_;
!
! BOOLEAN PROCEDURE ok_;
! BEGIN INTEGER i,j;
! REAL s2i,s2j,diff;
! FOR i:= ncase_ STEP -1 UNTIL 2 DO
! BEGIN IF k_[i] < kmin_ THEN GO TO exit_;
! IF max_[i] = min_[i] THEN GO TO exit_;
! s2i:= 3*Sqrt(s2_[i]/(k_[i]-1));
! WHILE s2i = 0 AND i >= 2 DO
! BEGIN i:= i - 1;
! IF k_[i] < kmin_ THEN GO TO exit_;
! s2i:= 3*Sqrt(s2_[i]/(k_[i]-1))
! END;
! IF i = 1 THEN GO TO exit_;
! FOR j:= i-1 STEP -1 UNTIL 1 DO
! BEGIN s2j:= 3*Sqrt(s2_[j]/(k_[j]-1));
! diff:= Abs(m_[i]-m_[j]);
! IF diff <= s2i THEN GO TO exit_ ELSE
! IF diff <= s2j THEN GO TO exit_;
! END j;
! END i;
! ok_:= TRUE;
!exit_: !
! ;
! END ok_;
!
!!%Decl;
!
!!%Init0;
!
! t_norm_:= inline("Time norm.:",Sysin).Getreal;
! jmin_:= inline("Min length of loop:",Sysin).Getint;
! kmin_:= inline("Min no. of test per case:",Sysin).Getint;
!
! oldlimit_:= limit_:= inline("Limit:",Sysin).Getreal;
! case_name_[1]:- Copy("0-Loop");
! FOR case_:= 1 STEP 1 UNTIL ncase_ DO
! ! *** We try with JMIN_ j-loops initially ;
! ! in order to adjust time (i.e. n_[case_]);
! BEGIN n_[case_]:= jmin_;
! na_[case_]:= case_;
! min_[case_]:= &30 END;
! n_[1]:= 90000*t_norm_;
! ! Approx. req. loops for nul-loop;
!
! case_:= 1;
! test_flag_:= TRUE;
!
! GO TO l1_;
!cont_: !
! ;
! IF delta_t_ <= 0.080 AND n_[case_] < 1 000 000 THEN
! BEGIN n_[case_]:=n_[case_]*10;
! case_:= case_ - 1 END ELSE
! IF delta_t_ > 0 THEN
! BEGIN n_[case_]:= n_[case_]*t_norm_/delta_t_;
! IF n_[case_] < jmin_ THEN n_[case_]:= jmin_;
! END;
!l1_: !
! ;
! case_:= case_ + 1;
! IF case_ <= ncase_ THEN GO TO test_;
! init_time_:= new_time_:= cptime;
! test_flag_:= FALSE;
! FOR case_:= 1 STEP 1 UNTIL ncase_ DO
! IF n_[case_] < kmin_ THEN n_[case_]:= kmin_;
!
! n_scramble_:= ncase_;
!
! IF (limit_-new_time_) < 1.1*t_norm_*ncase_*kmin_+1 THEN
! small:
! BEGIN Outtext("? Too small Time Limit.");
! Outimage;
! Outtext("Init.time:");
! Outfix(init_time_,0,5);
! Outimage;
! Outtext("Increase Time limit and/or decrease Min. no. of tests.");
! Outimage;
! Outtext("Will need at least ");
! top_:= init_time_ + 1.1*kmin_*ncase_*t_norm_ + 1;
! IF top_ < 1.1*limit_ + 1 THEN top_:= 1.1*limit_ + 1;
! Outfix(top_,0,5);
! Outtext(" Sec");
! Outimage;
! exit(1);
! END ELSE
! BEGIN Outtext("Est. time requirement:");
! Outfix(kmin_*ncase_*t_norm_+init_time_,0,5);
! Outtext(" Sec");
! Outimage;
! END;
!
! WHILE new_time_ < limit_ DO
! BEGIN
! IF (IF n_scramble_ = ncase_ THEN ok_ ELSE FALSE) THEN
! BEGIN test_flag_:= TRUE;
! GO TO stop_ END;
!restart_: !
! ;
! n_scramble_:= n_scramble_ + 1;
! IF n_scramble_ > ncase_ THEN
! BEGIN scramble(na_,1,ncase_,u_);
! n_scramble_:= 1;
! END;
! case_:= na_[n_scramble_];
! test_:
!!%Init1;
!
! j_n_:= n_[case_];
! IF case_ = 1 THEN
! BEGIN old_time_:= cptime;
! FOR j_:= 1 STEP 1 UNTIL j_n_ DO
!!%1;
! ;
! END ELSE
! IF case_ = 2 THEN
! BEGIN old_time_:= cptime;
! FOR j_:= 1 STEP 1 UNTIL j_n_ DO
!!%2;
! END ...;
! new_time_:= cptime;
! delta_t_:= new_time_-old_time_;
! IF test_flag_ THEN GO TO cont_;
! n_[case_]:= n_[case_]*(t_norm_/delta_t_ + 1)*0.5;
! delta_t_:= delta_t_/j_n_*1000;
! sigmean(s2_[case_],m_[case_],k_[case_],delta_t_);
! IF delta_t_ > max_[case_] THEN max_[case_]:= delta_t_;
! IF delta_t_ < min_[case_] THEN min_[case_]:= delta_t_;
!
! END big loop;
!
! Outtext(">>> Time Limit exceeded. Cpu:");
! Outfix(new_time_,1,5);
! Outimage;
! Eject(Line+1);
!stop_: !
! ;
!!%Names;
! top_:= m_[2];
! bestcase_:= 2;
! FOR j_:= 3 STEP 1 UNTIL ncase_ DO
! IF m_[j_] < top_ THEN
! BEGIN top_:= m_[j_];
! bestcase_:= j_ END;
!
! Outtext("Results - in milliseconds");
! Outimage;
! Outimage;
! Outtext("Name Case tests Runs R*M Sigma Mean "
! " Max Min [%]");
! Outimage;
! IF m_[bestcase_] = 0 THEN GO TO small;
! FOR j_:= 2 STEP 1 UNTIL ncase_ DO
! BEGIN m_[j_]:= m_[j_] - m_[1];
! max_[j_]:= max_[j_] - m_[1];
! min_[j_]:= min_[j_] - m_[1];
! END subtract zero loop;
! FOR j_:= 2 STEP 1 UNTIL ncase_ DO
! kvot_[j_]:= m_[j_]/m_[bestcase_]*100;
! FOR j_:= 2 STEP 1 UNTIL ncase_ DO
! BEGIN Outtext(case_name_[j_]);
! Setpos(7);
! Outint(j_-1,3);
! Outint(k_[j_],6);
! Outint(n_[j_],8);
! Outfix(n_[j_]*m_[j_],0,7);
! Outfix(Sqrt(s2_[j_]/(IF k_[j_] = 1 THEN 1 ELSE k_[j_]-1)),3,9);
! Outfix(m_[j_],3,9);
! Outfix(max_[j_],3,9);
! Outfix(min_[j_],3,9);
! IF j_ > 1 THEN
! Outfix(kvot_[j_],1,10);
! IF j_ = bestcase_ THEN Outtext(IF test_flag_ THEN " *" ELSE " (*)");
! Outimage;
! END;
!
! limit_:= limit_ + oldlimit_;
! top_:= &30;
! FOR j_:= 2 STEP 1 UNTIL ncase_ DO
! BEGIN m_[j_]:= m_[j_] + m_[1];
! IF m_[j_] < top_ AND j_ NE bestcase_ THEN
! BEGIN top_:= m_[j_];
! nestbestcase_:= j_ END;
! max_[j_]:= max_[j_] + m_[1];
! min_[j_]:= min_[j_] + m_[1];
! END;
! j_:= k_[bestcase_] + k_[nestbestcase_];
! IF j_ <= 2 THEN GO TO small;
! t_alfa_:= ! Total Sigma2 estimate (S);
! ((k_[bestcase_]-1)*s2_[bestcase_] +
! (k_[nestbestcase_]-1)*s2_[nestbestcase_]) / j_ *
! (1/k_[bestcase_]+1/k_[nestbestcase_]);
! t_alfa_:= Abs(m_[bestcase_]-m_[nestbestcase_])/Sqrt(t_alfa_);
! Outtext ("T(alfa):");
! Outfix(t_alfa_,2,6);
! Outtext(" Degr. of freedom:");
! Outint(j_,5);
! Outtext(" Cpu used:");
! Outfix(cptime,1,5);
! Outimage;
! exit(0);
! test_flag_:= FALSE;
! GO TO restart_;
! END dyn
!
!END program
!!%Stop;
BEGIN
EXTERNAL BOOLEAN PROCEDURE tmpout;
EXTERNAL INTEGER PROCEDURE scanint;
EXTERNAL PROCEDURE run,exit;
EXTERNAL TEXT PROCEDURE inline,tmpnam,conc,scanto;
EXTERNAL REF (Infile) PROCEDURE findinfile;
TEXT t,progname,crlf; INTEGER ncase,i;
REF (Outfile) prog; REF (Infile) tim;
PROCEDURE find(t); VALUE t; TEXT t;
BEGIN
WHILE tim.Image.Sub(2,t.Length) NE t DO
BEGIN tim.Inimage;
prog.Outtext(tim.Image.Sub(2,tim.Length-1).Strip);
prog.Outimage;
END;
END find;
crlf:- Blanks(2); crlf.Putchar(Char(13)); crlf.Putchar(Char(10));
progname:- tmpnam("TIM");
t:- inline(conc("Test Program name /",progname,"/:"),Sysin);
IF t =/= NOTEXT THEN progname:- t;
IF scanto(progname,'.') == progname THEN
BEGIN IF progname.Sub(progname.Length,1).Getchar NE '.' THEN
progname:- conc(progname,".");
END;
prog:- NEW Outfile(progname);
prog.Open(Blanks(IF Sysin.Length < 80 THEN 80 ELSE Sysin.Length));
tim:- findinfile("PRETIM.SIM[13,201]");
IF tim == NONE THEN
tim:- findinfile("PUB:PRETIM.SIM");
IF tim == NONE THEN
tim:- findinfile("PRETIM.SIM");
WHILE tim == NONE DO
tim:-
findinfile(Inline("Enter spec for PRETIM.SIM:",sysin));
tim.Open(Blanks(80));
t:- NOTEXT;
WHILE t == NOTEXT DO
BEGIN t:- inline("No. of cases:",Sysin);
ncase:= scanint(t);
IF ncase < 1 THEN t:- NOTEXT;
END;
find("!%E");
WHILE t =/= NOTEXT DO
BEGIN
t:- inline("Ext.Decl:",Sysin);
prog.Outtext(t); prog.Outimage;
END;
find("!%Ncase");
prog.Outtext("ncase_:="); prog.Outint(ncase+1,3);
prog.Outchar(';'); prog.Outimage;
find("!%Prefix");
t:- inline("Prefix:",Sysin);
prog.Outtext(t); prog.Outimage;
t:- Image;
find("!%D");
WHILE t =/= NOTEXT DO
BEGIN
t:- inline("Decl:",Sysin);
prog.Outtext(t); prog.Outimage;
END;
t:- Image;
find("!%Init0");
WHILE t =/= NOTEXT DO
BEGIN
t:- inline("Init0:",Sysin);
prog.Outtext(t); prog.Outimage;
END;
t:- Image;
find("!%Init1");
WHILE t =/= NOTEXT DO
BEGIN
t:- inline("Init1:",Sysin);
prog.Outtext(t); prog.Outimage;
END;
find("!%2");
FOR i:= 1 STEP 1 UNTIL ncase DO
BEGIN
t:- Image;
Outtext("Case"); Outint(i,2);
Outimage;
prog.outtext("BEGIN ");
WHILE t =/= NOTEXT DO
BEGIN
t:- inline("*",Sysin);
prog.Outtext(t); prog.Outimage;
END;
prog.Outtext(";END;"); prog.Outimage;
IF i < ncase THEN
BEGIN
prog.Outtext(";END ELSE IF case_ = ");
prog.Outint(i+2,2); prog.Outtext(" THEN"); prog.Outimage;
prog.Outtext("BEGIN old_time_:= cptime; FOR j_:= 1 STEP 1 UNTIL j_n_ DO");
prog.Outimage;
END i < ncase;
END i loop;
find("!%Names");
Outtext("Enter titles for tests (max 6 chars.)"); Outimage;
FOR i:= 1 STEP 1 UNTIL ncase DO
BEGIN
t:- Blanks(3); t.Putint(i);
t:- inline(conc("Case",t,":"),Sysin);
IF t =/= NOTEXT THEN
BEGIN prog.Outtext("case_name_["); prog.Outint(i+1,3);
prog.Outtext("]:- copy("""); prog.Outtext(t);
prog.Outtext(""");"); prog.Outimage;
END;
END i;
find("!%Stop");
prog.Close; tim.Close;
Outtext("Executing "); Outtext(progname); Outtext(": ");
Breakoutimage;
progname:- conc(progname,crlf,"LINK!",crlf);
tmpout("SIM",progname);
tmpout("LNK",conc("DSK: ",scanto(progname,'.'),"/E /G"));
run("SYS:SIMULA",2);
END