Mini recipes

wojdyr edited this page Sep 29, 2012 · 1 revision

Fityk Tips and Short Recipes

How to calculate area of functions when analytical formula is not known

you can calculate area numerically, for example:

print %_1.numarea(10,20,1000)

%_1 is the name of the function/peak. If you move mouse to the peak top, you see that name on the status bar. And it's also in other places, like the "functions" panel.

That command calculates area from x=10 to 20 using trapezoidal rule with 1000 steps.

How to benchmark a single command

Lua is useful here. os.clock () returns an approximation of the amount in seconds of CPU time used by the program. os.time() (at least in POSIX, Windows, and some other systems) returns seconds since some given start time (the "epoch").

Let's measure how long fit command runs. This will print real time (rounded to seconds):

lua a=os.time(); F:execute("fit"); F:out(os.difftime(os.time(),a))

and this processor time:

lua a=os.clock(); F:execute("fit"); F:out(os.clock()-a)