Sampling profiler
Factor handbook > Developer tools

Prev:Timing code and collecting statistics
Next:Object memory tools


The tools.profiler.sampling vocabulary provides an interface to Factor's sampling profiler. It provides words for running the profiler:
profile ( quot -- )


General statistics can then be collected:
total-time ( -- n )

gc-time ( -- n )

foreign-time ( -- n )

foreign-thread-time ( -- n )


More detailed by-function profile reports can be generated:
top-down ( -- tree )

top-down-max-depth ( max-depth -- tree )

cross-section ( depth -- tree )

flat ( -- flat )


The report data can then be printed:
profile. ( tree -- )


Profile data can be saved for future reporting:
most-recent-profile-data ( -- profile-data )

top-down* ( profile-data -- tree )

top-down-max-depth* ( max-depth profile-data -- tree )

cross-section* ( depth profile-data -- tree )

flat* ( profile-data -- flat )


For example, the following will profile a call to the foo word, and generate and display a top-down tree profile from the results:
[ foo ] profile top-down profile.