Post Reply 
Benchmark: Savage
10-12-2018, 10:46 AM (This post was last modified: 11-01-2018 08:27 AM by StephenG1CMZ.)
Post: #13
RE: Benchmark: Savage
Version 0.5 is not intended to change timings, but the timings for pythons-in-CAS do seem to be getting slower.

I seemed to have to run Savage V0.4 again before seeing the shorter times in V0.5 - which has me wondering which result is the more representative.
Is anyone else seeing a problem?

Outside the timed code, PRINT can be suppressed using boolean SP, and TEVAL timings are now returned by the main program.
GETNTIMES allows a timing to be repeated, to check repeatability.

Code:

//Benchmark: Savage 
 LOCAL CRID:="Savage Benchmark (HP Prime) V0.5"; 
 EXPORT NAMES:={
  "PPL       ",
  "MAKELIST  ",
  "PythonsCAS",
  "CAS       ",
  "CASinPPL  "};

 //OMITTED: "RAD" in the original:
 //User must select Radians

 EXPORT SP:=1;//ShowPRINT

 LOCAL AA;

 EXPORT SavagePPL()
 BEGIN
  LOCAL AA;
  AA:=1;
  FOR I FROM 1 TO 2499 DO
    AA:=TAN(ATAN(EXP(LN(√(AA*AA)))))+1
  END;
  RETURN AA;
 END;

 MLFOR ()
 BEGIN
  //LOCAL AA;
  RETURN AA:=TAN(ATAN(EXP(LN(√(AA*AA)))))+1;
 END;
 
 EXPORT SavageMAKE()
 BEGIN
  //LOCAL AA;
  AA:=1;
  MAKELIST(MLFOR(),AA,1,2499);
  RETURN AA;
 END;

#CAS
 SavageCAS1(f):=
 BEGIN
  LOCAL aa;
  aa:=1;
  FOR I FROM 1 TO 2499 DO
    aa:=TAN(ATAN(EXP(LN(√(aa*aa)))))+1
  END;
  RETURN (aa);
 END;

def savagepythonssyn() :
   local ii,aa
   aa=1
   for ii in range(1,2500):
     aa= tan(atan(exp(log(sqrt(aa*aa)))))+1
#END

 EXPORT SavageCASinPPL()
 BEGIN
  LOCAL aa;
  aa:=1;
  FOR I FROM 1 TO 2499 DO
    aa:=CAS(TAN(ATAN(EXP(LN(√(aa*aa))))))+1;
  END;
  RETURN (aa);
 END;

 RRR(RR)
 //REPORT RESULT,RELATIVE ERROR
 BEGIN
  RETURN {RR,((2500-RR)/2500)};
 END;

 //APPROX:
 //I FIND NO CLEAR WINNER BETWEEN PPL AND MAKE.
 //EXACT:
 //I FIND CAS2 CONSISTENTLY FASTER THAN CAS1
 
 SPRINT(ONE)
 BEGIN
  IF SP THEN
   PRINT(ONE);
  END;
 END;

 EXPORT GETNTIMES(FunN,NN)
 BEGIN
  LOCAL II;
  LOCAL TM:={};
  FOR II FROM 1 TO NN DO
   CASE
   IF  FunN==1 THEN TM(0):=TEVAL(SavagePPL);  END;
   IF  FunN==2 THEN TM(0):=TEVAL(SavageMAKE);  END;
   IF  FunN==3 THEN TM(0):=TEVAL(savagepysyn());  END;
   IF  FunN==4 THEN TM(0):=TEVAL(SavageCAS1);  END;
   IF  FunN==5 THEN TM(0):=TEVAL(SavageCASinPPL);  END;
   DEFAULT
   END;
  END;
  RETURN TM;
 END;

 EXPORT SAVAGE()
 BEGIN
  //LOCAL aa;
  LOCAL RR;
  LOCAL TM:={};
  IF SP THEN
   PRINT();
  END;
  SPRINT(CRID);
  TM(0):=TEVAL(RR:=SavagePPL());
  SPRINT({NAMES(1),TM(0),RRR(RR)});
  TM(0):=TEVAL(RR:=SavageMAKE());
  SPRINT({NAMES(2),TM(0),RRR(RR)});
  TM(0):=TEVAL(savagepysyn());
  //PRINT(TM(O));//DEBUG
  SPRINT({NAMES(3),TM(0),RRR(aa)});
  TM(0):=TEVAL(RR:=SavageCAS1(""));
  SPRINT({NAMES(4),TM(0),RRR(RR)});
  TM(0):=TEVAL(RR:=SavageCASinPPL());
  SPRINT({NAMES(5),TM(0),RRR(RR)});
 
  SPRINT(CRID);
  //MSGBOX(TM);
  RETURN TM;
 END;
Note: Neither V0.4 nor V0.5 compile in Beta on Android...
Version 0.2 can be compiled in Beta if "I" is changed to "i".
Update: See note regarding Python-in-CAS affecting indexing.

Stephen Lewkowicz (G1CMZ)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Benchmark: Savage - StephenG1CMZ - 12-03-2017, 11:40 PM
RE: Benchmark: Savage - StephenG1CMZ - 12-03-2017, 11:42 PM
RE: Benchmark: Savage - StephenG1CMZ - 12-05-2017, 10:51 PM
RE: Benchmark: Savage - StephenG1CMZ - 08-29-2018, 07:37 AM
RE: Benchmark: Savage - StephenG1CMZ - 09-28-2018, 07:20 PM
RE: Benchmark: Savage - StephenG1CMZ - 09-29-2018, 08:16 AM
RE: Benchmark: Savage - Albert Chan - 09-29-2018, 10:47 PM
RE: Benchmark: Savage - StephenG1CMZ - 09-30-2018, 07:20 AM
RE: Benchmark: Savage - Albert Chan - 09-30-2018, 11:15 AM
RE: Benchmark: Savage - Albert Chan - 09-30-2018, 02:13 PM
RE: Benchmark: Savage - StephenG1CMZ - 09-30-2018, 04:54 PM
RE: Benchmark: Savage - StephenG1CMZ - 10-12-2018, 09:51 AM
RE: Benchmark: Savage - StephenG1CMZ - 10-12-2018 10:46 AM
RE: Benchmark: Savage - StephenG1CMZ - 11-01-2018, 08:20 AM



User(s) browsing this thread: 1 Guest(s)