Use the Ltrace tool to track PHP library function call methods, Ltrace library functions _php Tutorial

Source: Internet
Author: User

Use the Ltrace tool to track PHP library function call methods, Ltrace library functions


The example in this article describes how to track PHP library function calls using the Ltrace tool. Share to everyone for your reference, as follows:

Maybe everyone is already familiar with using Strace to track system calls, today introduces a tool for tracking library functions Ltrace

Like I have this PHP code.

test.php:

<?php $y = ' 1380 '; $arr = Array (); for ($i = 0; $i <, $i + +) {   $arr [] = "{$i}";//intentionally enclose it in quotation marks as a string} for ($i = 0; $i <; $i + +) {   if (!in_arra Y ($y, $arr)) continue; }?>

Ltrace-c/usr/local/php/bin/php test.php (-c = Rollup)

You will see the following output:

% time   seconds Usecs/call   calls   function--------------------------------------------------------- 95.02  7.417240     368   20146 strtol2.15  7.160390     413   17316 memcpy1.63  5.522641     240   22966 free 0.67  2.275374   2275374     1 curl_global_cleanup 0.54  2.235466     617   3618 _ _ctype_tolower_loc 0.16  2.123547    1194   1778 strrchr 0.17  1.532224   22836 malloc 0.29  0.382083   5678 strlen

You can see that the strtol almost used 95.02% of the execution time, the bottleneck is found out. and PHP will attempt to convert string line numbers to long when In_array () is tested, which can be time consuming. So as long as the string is converted to shaping can greatly improve efficiency.

Ltrace is really a good tool.

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/PHPjc/1123841.html www.bkjia.com true http://www.bkjia.com/PHPjc/1123841.html techarticle Use the Ltrace tool to track PHP library function calls, Ltrace library functions This article describes methods for tracking PHP library function calls using the Ltrace tool. Share to everyone for your reference, specific ...

  • 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.