Register

FX CP400 Basic performance observations

Learn how to program. Code snippets for creating sprites etc. Submit your own or use those of others.
Junior Member
Posts: 7
Joined: Sun Aug 16, 2015 7:25 pm
Calculators: Casio Classpad fx-CP400

FX CP400 Basic performance observations

Postby D3F84U » Tue Aug 18, 2015 4:09 pm

Hello to everyone!

I decided to write here something that might help a beginner user develop faster applications by considering largest bottlenecks that if avoided my speedup execution time up to several times. I hope other users help us find more suggestions. I am still hoping someone will release C++ SDK so we can put this beautiful screen to use. Now to the topic.


Here are list of optimizations I had collected so far:
1. SetDecimal
First and most obvious optimization is using SetDecimal at the beginning of your program. This will speed up calculations but you will get a result in a decimal format and that is often all that is needed.

2. Output to screen
Using drawing and printing is time consuming. In a case of graphical output what needs to be there needs to be there but when it comes to text output, don't print too much. Loop of 50 calculations went from 10 to 3 seconds by just eliminating print of one number on each iteration. So instead of printing output store it to the list or matrix.

3. Memory allocation
This one is the most important when it comes to working with larger amounts of data. And this is the issue:
- Every time you add a new member to the list program pauses. That pause seems to be longer each time new element is added.
To illustrate the issue create two programs:
Code: Select all
Slow code

Local tstlst
{}=>tslst
For 1=>cnt To n Step 1
 cnt=>tstlst[cnt]
Next

Fast code

Local tstlst
{}=>tslst
fill(0,n)=>tstlst
For 1=>cnt To n Step 1
 cnt=>tstlst[cnt]
Next


fill takes about a second of time for list of dim 1000 and approx 3.5s for dim of 3000

For 200 iterations program that extends list on each iteration takes 8.5 seconds. Program that uses fill to allocate list at the beginning of the program uses only 2.5 seconds. Improvement: 3.4.
For 400 iterations slow code did it in 16 seconds while fast did it in 7. Improvement 2.29.
For 1000 iterations slow code did it in 41 seconds while fast did it in 23. Improvement 1.78.
For 2000 iterations slow code did it in 1m 23s seconds while fast did it in 51. Improvement 1.62.
For 3000 iterations slow code did it in 2m 7s seconds while fast did it in 1m 15s. Improvement 1.69.
For 4000 iterations slow code did it in 2m 52s seconds while fast failed with insufficient memory message.
For 5000 iterations slow code did it in 3m 39s seconds.




Good calculating!

Member
Posts: 40
Joined: Tue Dec 17, 2013 12:56 pm
Calculators: Casio fx-9860GII, Casio Classpad fx-CP400

Re: FX CP400 Basic performance observations

Postby PsySc0rpi0n » Sat Feb 25, 2017 9:39 pm

The "Slow code" returned an error:

Invalid Data Type


The "Fast code" returned the following error:

Domain

Junior Member
Posts: 7
Joined: Sun Aug 16, 2015 7:25 pm
Calculators: Casio Classpad fx-CP400

Re: FX CP400 Basic performance observations

Postby D3F84U » Sat Jan 30, 2021 11:08 pm

Replace "n" with arbitrary positive integer number:

Code: Select all
Slow code

Local tstlst
{}=>tslst
For 1=>cnt To 100 Step 1
 cnt=>tstlst[cnt]
Next

Fast code

Local tstlst
{}=>tslst
fill(0,100)=>tstlst
For 1=>cnt To 100 Step 1
 cnt=>tstlst[cnt]
Next

Return to Tutorials & Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests