Sheerpower Logo C.2  Built-in Code Profiler
Sheerpower includes a built-in code profiler. To activate it, add these statements to the top of your code:
debug on
stats on
Then, after you have run your code long enough or just before your program ends:
list stats
This writes profiling information to a file named myprogram_stats.txt where myprogram is the name of your program. The statistics file contains the names of every routine that is called. For each routine the amount of elapsed time spent in that routine and a count is provided. The count is the maximum number of times any statement within the routine was executed.

At the end of the file is a list of the top 20 routines that took the longest elapsed time to execute. This information lets you focus on which routines need to be optimized the most.
debug on
stats on
for idx = 1 to 10
  more_work
  do_it
  do_it2
next idx

list stats
stats off
debug off
stop

routine more_work
  x=x+1
  delay .05
end routine

routine do_it2
  delay .2
  x=x+1
end routine

routine do_it
  delay .2
  x=x+1
end routine

stop

Below is the profile as generated:
Sheerpower Profiling Statistics 07-SEP-2022 08:02:25 

C:\Sheerpower\stats.spsrc

0.62  10             routine more_work
2.02  10             routine do_it2
2.00  10             routine do_it

***** Longest Executing Routines *****
2.02  10             routine do_it2
2.00  10             routine do_it
0.62  10             routine more_work
************************
--- End of stats ---

Note: You will need to download Sheerpower to try the profiling feature. Also note that profiling only works when running from source code and not when running deployed (SPRUN) code.
Hide Description

    

       


    
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.
Wide screen