(10-04-2020 04:53 PM)grsbanks Wrote: Has anyone else noticed how damn fast this thing is using python?
I ran some benchmarks on this thing using both the built-in Casio Basic language and Python.
First, I get it to calculate \(\sum_{k=1}^n \sqrt[3]{e^{sin(atan(k))}} \) (a function with no intrinsic value other than it gets the calculator to chew through a bunch of transcendental functions) for various values of \(n\).
Using the built-in \(\sum \) function it gets through this in roughly (because timed with a stopwatch) 25 seconds for \(n=10^3\) or 220 seconds for \(n=10^4\). Using a Casio Basic program it does it in about 16 seconds for \(n=10^3\), 164 seconds for \(n=10^4\) or 1650 seconds for \(n=10^5\). Using a python program it does it in only 2 seconds for \(n=10^3\), 18 seconds for \(n=10^4\) or 184 seconds for \(n=10^5\). That's 10× faster than using Casio Basic, BUT with what appears to be greatly reduced precision.
Another test I do is to get a machine to solve the "N Queens" problem, not just for the first layout it finds but for all layouts. The kind of results I get are
Casio basic: 6×6 board 32 seconds, 7×7 board 139 seconds, 8×8 board 670 seconds
Python: 6×6 board 1 second, 7×7 board 3 seconds, 8×8 board 15 seconds, 9×9 board 76 seconds
Here, manipulating integers instead of floating point numbers, it's over 40× faster.
Would you post the exact program you used to test? For a valid benchmark, the same program should be used on all the tested calculators (or as close as possible). Here's the nqueens program I used:
Code:
def nqueens():
r=8
a=[0 for i in range(0,r+1)]
s=0
x=0
while True:
x+=1
a[x]=r
while True:
s+=1
y=x
while y>1:
y-=1
t=a[x]-a[y]
if t==0 or x-y==abs(t):
y=0
a[x]-=1
while a[x]==0:
x-=1
a[x]-=1
if y==1:
break
if x==r:
break
print(s)