JadeProfiler Class

The JadeProfiler class encapsulates the behavior required to configure what is profiled and reported by the Jade Interpreter. Statistics are captured about the execution of methods, focusing on two types of information.

It is recommended that when investigating application performance, only one of the Jade Profiler, Jade Monitor, or method profiling is used at any one time, as the results reported when any of these are combined is undefined.

Code coverage details are not recorded for methods with no source or with encrypted source.

Information about the execution times of methods in an application and the number of times methods are called can help developers improve the performance of an application by:

The following example shows the use of the JadeProfiler class to produce a standard profiler report.

vars
    prof : JadeProfiler;
begin
    prof := process.profiler;
    prof.fileName := "p:\profiling\dev\myprofile.log";
    prof.methodCount := 25;
    prof.reportCacheStatistics := false;
    prof.start;
    // call user methods here ...
    prof.report;
end;

Code coverage is a measure used in software testing to describe the degree to which the methods in a system have been executed. It is a useful measure to assure the quality of a set of tests, as opposed to directly reflecting the quality of the system under test. Code coverage can help testers and developers to:

The following example shows the use of the JadeProfiler class to perform code coverage.

vars
    prof : JadeProfiler;
begin
    prof := process.profiler;
    prof.codeCoverageFileName:= "erewhonshop_20090312_074611.ccd";
    prof.clearMethodCache;
    prof.startCodeCoverage;
    // call test methods here ...
    prof.reportCodeCoverage;
end;

Alternatively, you can enable code coverage programmatically by declaring a new application that initiates a special initialize method, as shown in the following example.

initializeCodeCoverage() updating;
begin
    create myCodeCoverage; // myCodeCoverage is a reference to JADEProfiler 
// on app. myCodeCoverage.startCodeCoverage(); // start coverage myInitialize(); // call standard Application class initialize method end;

To turn off code coverage when it is on, use the Application class finalize method, as shown in the following example.

myFinalize() updating;
begin
    if myCodeCoverage <> null then
        myCodeCoverage.stopCodeCoverage();
        myCodeCoverage.reportCodeCoverage();
        delete myCodeCoverage;
    endif;
    ...
end;

Use the start method to start the recording of times spent in Jade and external methods. These statistics are recorded until the stop method is executed, and they are output to file only when the report method is executed. Use this method to optimize your Jade code, by analyzing the performance of your methods. For example:

  1. Call the start method in your initialize method and then call the stop method after the methods whose performance you want to analyze have been called.

  2. Call the report method to output the recorded profile statistics to a file.

  3. Run the Jade application whose performance you want to monitor.

  4. Analyze the Jade Profiler report and then make the appropriate changes to your Jade methods, to optimize performance.

  5. Repeat steps 3 and 4 until you have made the performance improvements that you require.

Code coverage methods are used in testing Jade methods, as follows.

  1. The startCodeCoverage method is called in the setup method before the testing starts.

  2. The stopCodeCoverage method is called in the teardown method after the testing ends.

  3. The reportCodeCoverage method is called to output the code coverage statistics to a file.

4. The resetCodeCoverage method is called to clear all code coverage data.

For details about analyzing a code coverage file, see "Code Coverage" in Chapter 17 of the Developer's Reference. For details about the properties and methods defined in the JadeProfiler class, see "JadeProfiler Properties" and "JadeProfiler Methods", in the following subsections.

Object

(None)