Profiling is a way to provide feedback to the developper about where his program is spending CPU cycles.
It is intended to help him or her optimise the code through providing informations about what are the parts that consume more time than expected.
Profiling is done on a per thread base.
Several threads can be profiled at once, but each of them will have to start and stop the profiler for itself.
While profiling, a thread is stopped every 1/10 second, and the part of the code it was executing at that time is marked.
It is possible to futher more indicate how many functions over the currently executing one should also be marked.
Let's assume that when stopped, the program was executing function C called from function B, called from function A.
If recursion parameter is set to zero, only C will be counted 1.
If recursion parameter is set to one, both C and B will be counted 1.
Setting the recursion parameter to a high value is easier to start with because it will show you top down view of your program.
On the other hand, it is more likely to crash: profiling is not fully reliable.
Profiling in 64 bits mode might not work at all.
A module that want to profile some of it's code will include profiler.pli module:
then the code sequence will be:
The time spent to execute 'do something' is studied through stopping the program every 1/10 second as described in 'How it works' paragram.
In order to provide meaningfull information, a thread must run with profiler activated for several seconds, so it is often necessary to repeat program execution:
for (var Int lap) 1 1000
You can see /pliant/graphic/sample/rip.pli
In Pliant UI menu, select 'Dashboard' 'Processing' 'Profiler'
It will enable you to adjust the 'Recurse' parameter exposed in 'How it works' paragraph. Please note that you have to set it before having the profiled code run, not just at display result time.