Coder Social home page Coder Social logo

zgia / xhprof Goto Github PK

View Code? Open in Web Editor NEW

This project forked from longxinh/xhprof

0.0 0.0 0.0 1.91 MB

PHP7/PHP8 support

Home Page: http://pecl.php.net/package/xhprof

License: Apache License 2.0

Shell 0.12% JavaScript 11.76% C 19.31% PHP 48.83% CSS 1.14% HTML 18.69% M4 0.14%

xhprof's Introduction

xhprof for PHP7 and PHP8

Build Status Build status

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based navigational interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level inclusive and exclusive wall times, memory usage, CPU times and number of calls for each function. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.

This version supports PHP7 and PHP8

PHP Version

  • 7.2
  • 7.3
  • 7.4
  • 8.0
  • 8.1
  • 8.2

Installation

git clone https://github.com/longxinH/xhprof.git ./xhprof
cd xhprof/extension/
/path/to/php7/bin/phpize
./configure --with-php-config=/path/to/php7/bin/php-config
make && sudo make install

configuration add to your php.ini

[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof

php.ini configuration

    Options       Defaults Version Explain
xhprof.output_dir   "" All Output directory
xhprof.sampling_interval   100000 >= v2.* Sampling interval to be used by the sampling profiler, in microseconds
xhprof.sampling_depth   INT_MAX >= v2.* Depth to trace call-chain by the sampling profiler
xhprof.collect_additional_info   0 >= v2.1 Collect mysql_query, curl_exec internal info. The default is 0. Open value is 1

Turn on extra collection

php.ini adds xhprof.collect_additional_info

xhprof.collect_additional_info = 1

Options

xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
  • XHPROF_FLAGS_NO_BUILTINS do not profile builtins
  • XHPROF_FLAGS_CPU gather CPU times for funcs
  • XHPROF_FLAGS_MEMORY gather memory usage for funcs

Example

<?php

array(
    "main()" => array(
        "wt" => 237,
        "ct" => 1,
        "cpu" => 100,
    )
)
  • wt The execution time of the function method is time consuming
  • ct The number of times the function was called
  • cpu The CPU time consumed by the function method execution
  • mu Memory used by function methods. The call is zend_memory_usage to get the memory usage
  • pmu Peak memory used by the function method. The call is zend_memory_peak_usage to get the memory

PDO::exec

PDO::query

mysqli_query

$mysqli = new mysqli("localhost", "my_user", "my_password", "user");
$result = $mysqli->query("SELECT * FROM user LIMIT 10");
Output data
mysqli::query#SELECT * FROM user LIMIT 10

PDO::prepare

Convert preprocessing placeholders for actual parameters, more intuitive analytic performance (does not change the zend execution process)

$_sth = $db->prepare("SELECT * FROM user where userid = :id and username = :name");
$_sth->execute([':id' => '1', ':name' => 'admin']);
$data1 = $_sth->fetch();

$_sth = $db->prepare("SELECT * FROM user where userid = ?");
$_sth->execute([1]);
$data2 = $_sth->fetch();
Output data
PDOStatement::execute#SELECT * FROM user where userid = 1 and username = admin
PDOStatement::execute#SELECT * FROM user where userid = 1

Curl

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com");
$output = curl_exec($ch);
curl_close($ch);
Output data
curl_exec#http://www.baidu.com

PECL Repository

pecl

xhprof's People

Contributors

longxinh avatar billf avatar andypost avatar scottmac avatar slach avatar rarst avatar mikhainin avatar remicollet avatar robocoder avatar c9s avatar martinsupiot avatar erikwebb avatar davidsklar avatar cmb69 avatar zgia avatar kvakanet avatar joedevon avatar imageoptimiser avatar webdevel avatar rfay avatar oliworx avatar enumag avatar jwpage avatar glennpratt avatar nousefreak avatar zarv1k avatar dshafik avatar danez avatar draco2003 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.