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)