Xdebug documentation (v) Code Coverage analysis, xdebug documentation _php Tutorials

Source: Internet
Author: User

Xdebug documentation (v) Code Coverage analysis, xdebug documentation


The Code Coverage analysis allows you to know which line (or section) of the script is executing at the time of the request.

Related Settings

Xdebug.coverage_enable

Type: boolean, default value: 1, starting at

Xdebug >= 2.2

If set to 0, Xdebug does not set the built-in structure to allow code analysis, which accelerates xdebug faster, but code coverage analysis will not work.

Related functions

boolean xdebug_code_coverage_started ()

Returns a Boolean value to see if the code overlay analysis has started.

Example:

 
  PHP    var_dump(xdebug_code_coverage_started ());    Xdebug_start_code_coverage ();     Var_dump (xdebug_code_coverage_started ());? >  

Returns:

BOOL (FALSE)
BOOL (TRUE)

Array xdebug_get_code_coverage ()

Returns a structure that contains the script which line (including the reference file) is executing. The following presentation code overrides an example of specifying a file:

Example:

 
  PHP    xdebug_start_code_coverage ();    function A ($a) {        echo$a * 2.5;    }     function B ($count) {        for ($i$i$count  $i+ +) {            A ($i + 0.17);        }    }    B (6);    B (ten);     Var_dump (Xdebug_get_code_coverage ());? >  

Returns:

Array

'/home/httpd/html/test/xdebug/docs/xdebug_get_code_coverage.php ' =

Array

5 = int 1

6 = int 1

7 = int 1

9 = int 1

Ten = 1 int

One by one + int 1

1 = int

int 1

int 1

+ = int 1

+-INT 1

void xdebug_start_code_coverage ( [int options] )

Start Code Coverage Analysis

The function begins to collect code coverage information. This information is formed by a two-dimensional array with a one-dimensional index of two-level index of the execution file name as the line number. The element value indicates whether the row is being executed or it owns a row that failed to arrive.

Values returned for each row:

    • 1: The row has been executed
    • -1: The row was not executed
    • -2: The line has no executable code

A value of -1 is returned only if the xdebug_cc_unused is turned on, and the 2 value is only turned on when Xdebug_cc_unused and Xdebug_cc_dead_code are on.

The function has two options to enumerate the values:

Xdebug_cc_unused

Turns on the detection code and explains which behavior executable code. Without this, the returned array contains only the line numbers that were actually executed.

Xdebug_cc_dead_code

Start an additional analysis to show which code can be executed.

If these options are turned on, performing a significant slowdown in code coverage analysis speed.

The following example shows how to use the options:

Example:

 
  Phpxdebug_start_code_coverage (xdebug_cc_unused |  Xdebug_cc_dead_code);? >

void xdebug_stop_code_coverage ( [int cleanup=true] )

Stop Code Coverage Analysis

The function stops gathering information, and the information is purged in memory. If you pass the "false" argument, the code overwrite information is not cleared and allows you to resume information collection again using xdebug_start_code_coverage () .

http://www.bkjia.com/PHPjc/1133565.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133565.html techarticle Xdebug Document (v) Code Coverage analysis, XDEBUG document code Coverage analysis enables you to know which line (or section) of the script is executing when requested. Related Settings Xdebug.coverage_enab ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.