OScript API/Built-in Package Index

Class: Profiler

The Profiler package provides a small set of functions for enabling and controlling OScript profiler output.

OScript profilers collect timing information during OScript code execution and save this data to profiler output files. Profilers run on a per-thread basis, so profile data files represent the data collected from a single thread.

The profile data may be output in two formats. By default, output is written in Callgrind format, and can be open by a variety of utility programs, including KCachegrind. KCachegrind allows visualization and analysis of profiling data, and can view multiple profile data files at the same time.

Profile data may also be output in raw comma separated values format (CSV), by specifying a profile file name with a .csv extension.

For either of the above formats, the profiler also supports GZIP compression of the data file as it is written by specifying a .zip extension (e.g. profiledata.out.zip).

Class Attributes

Profiler output will include calls to OScript functions and OScript builtins.

Profiler output will only include calls to OScript functions.

Profiler output is disabled.

Class Methods

Returns the current Profiler output level.

SetLevel( Integer level )

Sets the current Profiler output level.

Start( String fileName, Integer level, Boolean justThisRequest )

Create a new OScript profiler.

Stop( Boolean justThisRequest )

Stops the current OScript profiler.

Class Attributes

Profiler output will include calls to OScript functions and OScript builtins.

Integer LEVEL_CALLS

Profiler output will only include calls to OScript functions.

Integer LEVEL_OFF

Profiler output is disabled.

Class Methods

GetLevel

Integer GetLevel()

Returns the current Profiler output level.

Returns:

The current Profiler output level. Profiler.LEVEL_OFF if there is no active profiler.

SetLevel

Boolean SetLevel( Integer level )

Sets the current profiler output level.

Parameters

level

The profiler output level to set.

Returns:

True if successful, false if not.

Start

Boolean Start( String fileName,
               Integer level,
               Boolean justThisRequest )

Create a new OScript profiler for the calling thread.

Parameters

fileName

The profiler output file name.

level

The profiler output level to set (default is Profiler.LEVEL_BUILTINS).

justThisRequest

True if the profiler should stop after the current request completes, false if the profiler should run until stopped (default is false).

Returns:

Boolean indicating success in creating the new profiler.

Stop

Boolean Stop( Boolean justThisRequest )

Stops the current OScript profiler for the calling thread.

Parameters

justThisRequest

True if the profiler should stop profiling only until the current request completes, false if the profiler should completely stop profiling (default is false).

Returns:

True if an active profiler was stopped, false if there was no profiler running.

 Copyright © 2021 OpenText Corporation. All rights reserved.