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