PROFILER_BEGIN()

Syntax

PROFILER_BEGIN()

Description

Insert the PROFILER_BEGIN() command in an Xbasic script at the point that you want to begin profiling a script. Insert the PROFILER_END()command at the point that you want to end profiling a script. When the PROFILER_END() command is encountered, Alpha Five dumps a report to the Trace window showing each line in your Xbasic script that was executed, the number of times it was executed, and the time taken to execute the command.

Profiling a script can help you determine which parts of a script might be taking a long time to execute. It can also help you debug your script because in complex scripts with lots of loops and branches, it can be difficult to see exactly which lines in your script actually get executed. The profiler report shows you what got executed.

Supported By

Alpha Five Version 5 and Above

Limitations

Desktop applications only.

Examples

Assume that you have created this script:

profiler_begin()

t = table.open("customer")

t.fetch_first()

while .not. t.fetch_eof()

    t.change_begin()

    t.Company = upper(t.Company)

    t.change_end(.T.)

    t.fetch_next()

end while

t.close()

profiler_end()

After running this script, the Trace window will show:

Script profiler

Line   Tot Time  Cnt Source

========================================================

  1  0.014018  1 t = table.open("customer")

  2  0.000228  1 t.fetch_first()

  3  0.000256  1 while .not. t.fetch_eof()

  4  0.008717 63 t.change_begin()

  5  0.009599 63 t.Company = upper(t.Company)

  6  0.240749 63 t.change_end(.T.)

  7  0.007564 63 t.fetch_next()

  8  0.004301 63 end while

  9  0.001136  1 t.close()

=======================================================

See Also

Script Functions