再不用按F5了!

On 2012/04/24, in WEB开发, by lyndon

前提:LINUX系统、安装inotify-tools、xdotool、双显示器

作用:保存代码时,自动刷新浏览器,再不用按F5了!

inotifywait -mrq  –exclude “.svn”  -e close_write /data/www/source | while read line; do
id=`xdotool getactivewindow | head -1`
xdotool search –onlyvisible –class ‘chrome’ windowfocus key –clearmodifiers ctrl+r
#xdotool search –onlyvisible –class ‘firefox’ windowfocus key –clearmodifiers ctrl+r
#xdotool search –onlyvisible –class ‘opera’ windowfocus key –clearmodifiers ctrl+r

xdotool windowactivate $id

done

Tagged with:  

php程序运行时间记录

On 2010/09/24, in PHP, by lyndon

调试php程序时,有时需要分析php程序各不会运行的时间,方法有很多,比较好的是xdebug+wincachegrind(win,要看Caller Map需安装Graphviz)或kcachegrind(linux),也可以用facebook出品的xhprof,不过这些都要安装,比较麻烦,自己写了个简单的。

使用方法

runtime::log_start(‘loop’);   //开始

for($i=0;$i<10;$i++){

runtime::log_start(‘func1′);   //开始

function1();

runtime::log_end(‘func1′);  //结束

}

runtime::log_end(‘loop’);  //结束

源码如下:


Continue reading »

Tagged with: