profile
profile — collects statistics on function usage and run time.
profile (on_p, tick_nanosecs?)
on_pIf non-nil,
start profiling, else stop profiling.
tick_nanosecsReset the QNX 4 tick size to this many nanoseconds before beginning to profile.
The previous state of profiling.
This function starts (or stops) collecting statistics on the usage and
run time of all functions in the system. The profile mechanism uses an
interrupt on the QNX 4 tick clock, and so must run with root permissions. If
the optional tick_nanosecs argument is provided, this
function will reset the tick size. Otherwise, it will profile using the
current tick size. The smaller the tick size, the more precise is the
profile result.
The following program gives the output shown below.
#!/usr/cogent/bin/gamma
require_lisp("Profile.lsp");
e_list = list();
j = 0;
function print_reverse()
{
with i in cdr(argv) do
{
e_list = cons(i, e_list);
j++;
}
princ("The numbers in reverse order are:\n", e_list, "\n");
}
function main()
{
profile(t);
print_reverse();
profile(nil);
profiled_functions();
princ("Function calls: ", function_calls(cons),"\n");
princ("Function runtime: ", function_runtime(cons),"\n");
}
[sh]$ ex_profile.g 1 2 3 4 5The numbers in reverse order are:
(5 4 3 2 1)
Function Calls Total Time
+++ 5 4e-06
cdr 1 0
cons 5 2e-06
for 1 2.3e-05
profile 1 1e-06
setq 5 3e-06
princ 1 0.006502
print_reverse 1 0.006534
progn 6 0.006546
Function calls: 5
Function runtime: 1.9999999999999999095e-06