php ticks 调试应用
declare (ticks=1); register_tick_function( 'do_profile' ); register_shutdown_function( 'show_profile' ); $profile = array (); $last_time = microtime(true); a(); function do_profile() { global $profile , $last_time ; $bt = debug_backtrace(); if ( count ( $bt ) <= 1) { return ; } $frame = $bt [1]; unset( $bt ); $function = $frame [ 'function' ]; if (!isset( $profile [ $function ])) { $profile [ $function ] = array ( 'time' => 0, 'calls' => 0 ); } $profile [ $function ][ 'calls' ]++; $profile [ $function ][ 'time' ] += (microtime(true) - $last_time ); $last_time = microtime(true); } function show_profile() { global $profile ; print_r( $profile ); } function a() { usleep(50 * 1000); b(); } function b() { usleep(500 * 1000); c(); } function c() { usleep(5000 * 1000); } |
输出:
Array
(
[a] => Array
(
[time] => 0.0511748790741
[calls] => 2
)
[b] => Array
(
[time] => 0.500598907471
[calls] => 2
)
[c] => Array
(
[time] => 5.00052690506
[calls] => 1
)
)
php ticks 调试应用的更多相关文章
- NodeJS的代码调试和性能调优
本文转自我的个人博客. NodeJS 自 2009 年显露人间,到现在已经六个年头了,由于各种原因,中间派生出了个兄弟,叫做 iojs,最近兄弟继续合体,衍生出了 nodejs4.0 版本,这东西算是 ...
- WinDbg调试CPU占用高的问题 试验+实战 《第七篇》
一.High CPU试验 1.示例代码 static void Main(string[] args) { Console.Clear(); Console.WriteLine("到命令行下 ...
- php declare (ticks = N)
A tick is an event that occurs for every N low-level tickable statements executed by the parser with ...
- Windbg在软件调试中的应用
Windbg在软件调试中的应用 Windbg是微软提供的一款免费的,专门针对Windows应用程序的调试工具.借助于Windbg, 我们常见的软件问题:软件异常,死锁,内存泄漏等,就可以进行高效的排查 ...
- Windbg内核调试之三: 调试驱动
这次我们通过一个实际调试驱动的例子,来逐步体会Windbg在内核调试中的作用.由于条件所限,大多数情况下,很多人都是用VMware+Windbg调试内核(VMware的确是个好东西).但这样的调试需要 ...
- 【php学习笔记】ticks篇
1. 什么是ticks 我们来看一下手冊上面对ticks的解释: A tick is an event that occurs for every N low-level statements exe ...
- 使用WinDbg内核调试[转]
Technorati 标签: windbg,内核调试 WINDOWS调试工具很强大,但是学习使用它们并不容易.特别对于驱动开发者使用的WinDbg和KD这两个内核调试器(CDB和NTSD是用户态调试器 ...
- 修改公司VS_UCOS工程BUG调试过程说明
说明:公司里的工程中,使用VS_UCOS来调试应用程序.业务逻辑.方法是嵌入式和VS分别建一个工程,把底层驱动部分分别添加各自需要的源文件,头文件使用同一个.也就是嵌入式的驱动函数名和参数和VS的函数 ...
- Android内核的编译和调试
本文博客地址:http://blog.csdn.net/qq1084283172/article/details/70500488 一.Android内核源码的选择 Android手机设备内核源码的调 ...
随机推荐
- hdoj 2097 Sky数
Sky数 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- js避免全局污染
避免声明全局变量,以免发生冲突
- 二、FreeMarker 模版开发指南 第二章 数值和类型
章节内容如下: 基本内容 类型 一.基本内容 简介 什么是数值? 什么是类型? 数据模型是哈希表 a.简介 理解数值和类型的概念是理解数据模型的关键所在.然而,数值和类型的概念并不局限于数据模型, ...
- 编写一个Java应用程序,设计一个汽车类Vehicle,包含的属性有车轮个数 wheels和车重weight。小车类Car是Vehicle的子类,其中包含的属性有载人数 loader。卡车类Truck是Car类的子类,其中包含的属性有载重量payload。每个 类都有构造方法和输出相关数据的方法。最后,写一个测试类来测试这些类的功 能。
package car; public class Vehicle { //定义成员变量 private int wheels; private double weight; public int g ...
- android studio里的build.gradle基本属性
//声明是android 程序 apply plugin: 'com.android.application' android { //编译SDK版本 compileSdkVersion 23 // ...
- 通过存储过程进行分页查询的SQL示例
--创建人:zengfanlong --创建时间:-- :: --说明:根据公司简写代码获取当前待同步的气瓶档案数据(分页获取) ALTER PROCEDURE [UP_GasBottles_GetS ...
- Swift入坑--block的定义
typealias methodCompletionBlock = (String)->Void
- java nio 抛出NonWritableChannelException异常
抛出异常的代码在此处: MappedByteBuffer buffer = channel.map(MapMode.READ_WRITE, 0, avalible); 其中channel是一个file ...
- php.ini 中开启短标签 <?=$?>
制参数: short_open_tag = On如果设置为Off,则不能正常解析类似于这样形式的php文件:<?phpinfo()?> 而只能解析<?phpphpinfo()?> ...
- Understanding transient variables in Java and how they are practically used in HashMap---reference
What is the significance of the transient keyword in Java? If you know the answer, good! you are a p ...