Post Reply 
Summation based benchmark for calculators
09-06-2018, 11:28 PM (This post was last modified: 09-06-2018 11:37 PM by ijabbott.)
Post: #140
RE: Summation based benchmark for calculators
(09-06-2018 10:23 PM)Albert Chan Wrote:  Does Micro Python support default arguments, like regular Python ?

If Yes, changing def RunTest() to def RunTest(pow=pow, exp=exp, sin=sin, atan=atan) should be faster.
Now, all variables are locals (pow, exp, sin, atan are variables too)

You could assign those as variables within RunTest() itself.

Code:
import math
def RunTest(n):
  pow=math.pow
  exp=math.exp
  sin=math.sin
  atan=math.atan
  x=0
  for i in range(1,n+1):
    x=x+pow(exp(sin(atan(i))),1/3)
  print(x)

RunTest(100000)

Finishes in ~53 seconds on fx-CG50.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Summation based benchmark for calculators - ijabbott - 09-06-2018 11:28 PM



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