Post Reply 
HP Prime: a student's view
08-31-2021, 03:14 PM
Post: #12
RE: HP Prime: a student's view
Now I did the performance checks on my G2. Here are my programs and results.
Code:
#PYTHON perf
from math import *
from hpprime import *
lo = 100000

def perf_ind():
   for i in range(lo):
      r0 = 10
      # for l in range(10):
      while r0 > 0:
         x = r0
         x += 1
         x -= 4.567e-4
         x += 70
         x -= 69
         x *= 7
         x /= 11
         r0 -= 1
      x = log(x)
      x = sin(x)
      x = sqrt(x)
      x = sqrt(x)
   print("* x:  ",x)

print("") 
print("Python: start, lo: ",lo)
t = eval("ticks()")
perf_ind()
t = (eval("ticks()") -t) / 1000
print("* end. time: ",t)
indx = (34 / t) * lo
print("* Index: ", indx)
----------------------------------
//  HPPPL:
PerfInd(lo);
EXPORT Perf()
 BEGIN
 Local t,l0,indx,loops = 10000;
 PRINT(".");
 PRINT("HPPPL start, loops = " + loops);
 t := TICKS;
 PerfInd(loops);
 t := (TICKS -t) /1000;
 PRINT("* Time: " + t);
 indx := (34 / t)  * loops;
 PRINT("* Index: " + indx);
 PRINT("");
END;

PerfInd(l0)
BEGIN
 LOCAL i, x, r0;
 // PRINT("* start sub, loops = " +l0); 
 FOR i FROM  1 TO l0 DO
    r0 := 10; 
    WHILE (r0) > 0 DO 
         x := r0;
         x := x + 1;
         x := x - 4.567e-4;
         x := x + 70;
         x := x - 69;
         x := x * 7;
         x := x / 11;
        r0 := r0 - 1; 
       END;  // while
       x = log(x);
       x = sin(x);
       x = sqrt(x);
       x = sqrt(x);
  END;   // for
  PRINT("... x=  " + x);
END;
are these programs comparable?

my results:
- HPPPL: 22 460 (10 000 loops, 15 sec)
- Python: 529 100 (100 000 loops, 6.4 sec)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP Prime: a student's view - Liam Hays - 08-30-2021, 01:11 AM
RE: HP Prime: a student's view - Liam Hays - 08-31-2021, 01:30 AM
RE: HP Prime: a student's view - Thomas_Sch - 08-31-2021 03:14 PM
RE: HP Prime: a student's view - parisse - 08-31-2021, 07:30 PM
RE: HP Prime: a student's view - Liam Hays - 08-31-2021, 11:20 PM
RE: HP Prime: a student's view - jte - 09-01-2021, 10:43 PM
RE: HP Prime: a student's view - Liam Hays - 09-03-2021, 01:31 AM
RE: HP Prime: a student's view - jte - 09-05-2021, 03:44 PM
RE: HP Prime: a student's view - jte - 09-05-2021, 06:16 AM
RE: HP Prime: a student's view - pinkman - 09-03-2021, 09:30 PM
RE: HP Prime: a student's view - Liam Hays - 09-04-2021, 01:30 AM
RE: HP Prime: a student's view - Liam Hays - 09-04-2021, 04:49 PM
RE: HP Prime: a student's view - ijabbott - 09-04-2021, 08:44 AM



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