1.
<pre name="code" class="php">$MINVALUE=-100;
$MAXVALUE=100;
$timetmp_cmd="daperf -points 5 -cpubusy -longterm ".$cmd_longtime." | awk -F \" \" 'NR==6{print $5}'";
$timetmpmin_cmd="daperf -points 5 -cpubusy -longterm ".$cmd_longtime." -increment ".$MINVALUE." | awk -F \" \" 'NR==6{print $5}'";
$timetmpmax_cmd="daperf -points 5 -cpubusy -longterm ".$cmd_longtime." -increment ".$MAXVALUE." | awk -F \" \" 'NR==6{print $5}'";
$timetmp=explode(":",`$timetmp_cmd`);
$timetmpmin=explode(":",`$timetmpmin_cmd`);
$timetmpmax=explode(":",`$timetmpmax_cmd`);
$year=substr($timetmp[0],0,4);
$month=substr($timetmp[0],4,2);
$day=substr($timetmp[0],6,2);
$hour=substr($timetmp[0],9,2);
$minute=substr($timetmp[0],11,2);
$sec=substr($timetmp[0],13,2);
$timetmp=$year."-".$month."-".$day." ".$hour.":".$minute.":"."$sec";
$year=substr($timetmpmin[0],0,4);
$month=substr($timetmpmin[0],4,2);
$day=substr($timetmpmin[0],6,2);
$hour=substr($timetmpmin[0],9,2);
$minute=substr($timetmpmin[0],11,2);
$sec=substr($timetmpmin[0],13,2);
$timetmpmin=$year."-".$month."-".$day." ".$hour.":".$minute.":"."$sec";
$year=substr($timetmpmax[0],0,4);
$month=substr($timetmpmax[0],4,2);
$day=substr($timetmpmax[0],6,2);
$hour=substr($timetmpmax[0],9,2);
$minute=substr($timetmpmax[0],11,2);
$sec=substr($timetmpmax[0],13,2);
$timetmpmax=$year."-".$month."-".$day." ".$hour.":".$minute.":"."$sec";
$cmd_tmp="date +%s -d '".$timetmp."'";
$cmd_min="date +%s -d '".$timetmpmin."'";
$cmd_max="date +%s -d '".$timetmpmax."'";
$min_tt=((`$cmd_min`-`$cmd_tmp`)/60/20);
$max_tt=((`$cmd_max`-`$cmd_tmp`)/60/20);
2.局部刷新性能图示
var max_bt=<?php echo $max_tt ?>;
var min_bt=<?php echo $min_tt ?>;
var increment=<?php if(isset($increment))echo $increment; else echo 0; ?>;
function decrease()
{
var number = Math.random();
var obj=document.getElementById("pic1");
url="<?php echo 'srcPerMonitor.php?type='.$type.'&controller='.$controller.'&vdType='.$vdType.'&cache='.$cache.'&DGname='.$DGname.'&VDname='.$VDname.'&pbufMc=1&rwtype='.$rwtype.'&period='.$period.'&longtermtime='.$longtermtime.'&circle='.$circle.'&circle_range='.$circle_range.'&circle_getval='.$circle_getval.'&circle_rate='.$circle_rate; ?>";
if(increment > min_bt)
increment--;
obj.src = url+"&v="+number+"&increment="+increment;
<?php if(!strcmp($type,"pbufMc")){ ?>
var obj2=document.getElementById("pic2");
url2="<?php echo 'srcPerMonitor.php?type='.$type.'&controller='.$controller.'&vdType='.$vdType.'&cache='.$cache.'&DGname='.$DGname.'&VDname='.$VDname.'&pbufMc=2&rwtype='.$rwtype.'&period='.$period.'&longtermtime='.$longtermtime.'&circle='.$circle.'&circle_range='.$circle_range.'&circle_getval='.$circle_getval.'&circle_rate='.$circle_rate; ?>";
obj2.src = url2+"&v="+number+"&increment="+increment;
<?php } ?>
}
function increase()
{
var number = Math.random();
var obj=document.getElementById("pic1");
url="<?php echo 'srcPerMonitor.php?type='.$type.'&controller='.$controller.'&vdType='.$vdType.'&cache='.$cache.'&DGname='.$DGname.'&VDname='.$VDname.'&pbufMc=2&rwtype='.$rwtype.'&period='.$period.'&longtermtime='.$longtermtime.'&circle='.$circle.'&circle_range='.$circle_range.'&circle_getval='.$circle_getval.'&circle_rate='.$circle_rate; ?>";
if(increment < max_bt)
increment++;
obj.src = url+"&v="+number+"&increment="+increment;
<?php if(!strcmp($type,"pbufMc")){ ?>
var obj2=document.getElementById("pic2");
url2="<?php echo 'srcPerMonitor.php?type='.$type.'&controller='.$controller.'&vdType='.$vdType.'&cache='.$cache.'&DGname='.$DGname.'&VDname='.$VDname.'&pbufMc=2&rwtype='.$rwtype.'&period='.$period.'&longtermtime='.$longtermtime.'&circle='.$circle.'&circle_range='.$circle_range.'&circle_getval='.$circle_getval.'&circle_rate='.$circle_rate; ?>";
obj2.src = url2+"&v="+number+"&increment="+increment;
<?php } ?>
}
3.计算PHP执行时间代码示例
< ?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0;
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function start()
{
$this->StartTime = $this->get_microtime();
}
function stop()
{
$this->StopTime = $this->get_microtime();
}
function spent()
{
return round(($this->StopTime - $this->StartTime) * 1000, 1);
}
}
//例子
$runtime= new runtime;
$runtime->start();
//你的代码开始
$a = 0;
for($i=0; $i<1000000; $i++)
{
$a += $i;
}
//你的代码结束
$runtime->stop();
echo "页面执行时间: ".$runtime->spent()." 毫秒";
?>
4.
PHP Speedy
http://aciddrop.com/2008/07/15/php-speedy-wp-version-047-works-with-wp26/
http://aciddrop.com/php-speedy/
5时间转时间戳
time1=$(date +%s -d '1990-01-01 01:01:01')
6.最后修改成的时间控件
<script type="text/javascript" src="../inc/My97DatePicker/WdatePicker.js"></script>
<input type="text" name="longtermtime" id="longtermtime" style="width:130px;height:14px;" value="<?php echo isset($date)?$date:'Select time'; ?>" οnclick="this.value='';WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'MM/dd/yyyy - HH:mm:00',maxDate:'%y-%M-%d',lang:'en',onpicked:function(){changeTime();}})" />