PHPÊý¾Ý½á¹¹——ðÅÝÅÅÐòÓë¿ìËÙÅÅÐòµÄ±È½Ï
//ðÅÝÅÅÐò£¨Êý×éÖÐʵÏÖ£©
function bubble_sort($arr) {
$cnt = count($arr);
if($cnt<=0) return false;
for($i=0; $i<$cnt;$i++) {
for($j=$cnt-1; $j>$i;$j--) {
if($arr[$j]<$arr[$j-1]) {
$tmp = $arr[$j];
$arr[$j] = $arr[$j-1];
$arr[$j-1]=$tmp;
}
}
}
return $arr;
}
//¿ìËÙÅÅÐò£¨Êý×éÅÅÐò£©
function quicksort($arr) {
if(count($arr)<=1) return $arr;
$key = $arr[0];
$left_arr = array();
$right_arr = array();//н¨Ò»¸öÊý×é
for($i=1; $i<count($arr); $i++) {
if($arr[$i]<$key) {
$left_arr[] = $arr[$i];
} else {
$right_arr[] = $arr[$i];
}
}
$left_arr = quicksort($left_arr);
$right_arr = quicksort($right_arr);
return array_merge($left_arr,array($key),$right_arr);
}
for($i=0;$i<10000;$i++) {//²âÊÔÊý×é
$arr1[$i] = rand(0,10000);
}
$time_start = explode(" ",microtime());
bubble_sort($arr1);
$time_end = explode(" ", microtime());
echo "ðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
echo '----------------------------------'.'<br>';
$time_start = explode(" ",microtime());
quicksort($arr1);
$time_end = explode(" ", microtime());
echo "¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔ¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
echo '-------------------------------------'."<br>";
$time_start = explode(" ",microtime());
sort($arr1);//phpÄÚÖöÔÊý×éÅÅÐòº¯Êý
$time_end = explode(" ", microtime());
echo "PHPÄÚÖú¯ÊýÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔPHPÄÚÖú¯ÊýÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
²âÊÔ½á¹û£º
ðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:22.864297151566
----------------------------------
¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:0.22899389266968
--------
Ïà¹ØÎĵµ£º
˵µ½¼Æ»®ÈÎÎñ´ó¼Ò¿ÉÄܶ¼Ïëµ½ÓÃcrontabÀ´ÊµÏÖ¡£¿ÉÊDz¢²»ÊÇËùÓÐÈ˶¼ÊÇʹÓÃlinuxϵͳ£¬Ò²²»ÊÇËùÓÐÈ˶¼ÓжÀÁ¢·þÎñÆ÷¡£ÕâʱºòÈçºÎÓÃphpÀ´
ʵÏּƻ®ÈÎÎñÄØ¡£
º¯Êý- ignore_user_abort()
£¬
Õâ¸öº¯Êý¿ÉÒÔ°ïÖúÎÒÃÇʵÏÖÏñlinuxÖеÄcronÒ»ÑùʵÏּƻ®ÈÎÎñ£¬ÏÂÃæÒ»ÆðÀ´¿´Ï¸ÃÈçºÎÀ´ÊµÏÖ¡£
¸Ãº¯Êý°´ÕÕ×ÖÃæÒâ˼¾ÍÊÇ“ºöÂÔÓû§Ö ......
ÔÚPHPÖÐʹÓÃÍ·Îļþ£¬»áÉæ¼°Á½¸öº¯Êý£ºinclude()ºÍrequire()¡£ÕâÁ½¸öº¯Êý²î±ðºÜС£¬È´ºÜÖØÒª£¬ËùÒÔÎÒÃÇÒªÈÏÕæÑо¿Ò»Ï¡£
require()º¯Êý¹¤×÷·½Ê½ÓëXSSIÏàÀàËÆ£»²»¹ÜÔÚ³ÌÐòµÄÄĸö²¿·ÖʹÓÃÁËÕâ¸öº¯Êý£¬Ö»ÓгÌÐòÒ»¿ªÊ¼ÔËÐУ¬Í·ÎļþµÄÄÚÈݾͱ»×÷Ϊ³ÌÐò±¾ÉíµÄÒ»²¿·ÖÀ´´¦
Àí¡£Òò´Ë£¬Èç¹ûÄúÔÚÒ»¸öÌõ¼þÅж¨Óï¾äÖÐʹÓÃÁËrequire()º¯Ê ......
½ñÌìÍ·ÄÔÒ»ÈÈ£¬Ïë¿´Ò»ÏÂÒ³ÃæÔÚÖ´ÐеĹý³ÌÖÐÕ¼ÓÃÁ˶àÉÙÄڴ棬ÎÒÒ²²»ÖªµÀÕâÑù×öµÄÄ¿µÄÊÇʲô£¬¿ÉÄÜÊdzöÓÚÎҵĹßÐÔ˼ά°É¡£²»¹ýÕâÑù×öÒ²²»ÊÇÍêȫûÓã¬
Äã¿ÉÒÔÇå³þµÄÖªµÀÄÄЩҳÃæÕ¼ÓõÄÄÚ´æ±È½Ï¶à£¬ÌرðÊǶÔÓÚʹÓù²ÓÃÖ÷»úµÄÍøÕ¾£¬Ò»°ã¿Õ¼äÉ̶¼»áÏÞÖÆÿ¸öÍøÕ¾µÄ×ÊÔ´Õ¼ÓÃÇé¿öµÄ£¨°üÀ¨cpuºÍÄڴ棩¡£ÍòÒ»ÔÚÎÒ
ÃDz»ÖªµÀµÄÇé¿öÏ£ ......
<?php
/*
Version: v1.0
CopyRight Davis.z 2010
Creation Date 2010-02-25
----------------------- Table Script ------------------------
CREATE TABLE [dbo].[T_Employee](
[Name] [nvarchar](50) COLLATE Korean_90_CS_AS NOT NULL,
[Age] [nvarchar](5) COLLATE Korean_90_CI_AS NULL,
[ ......
½ñÌì2010-02-26£¬¿ªÊ¼ÎÒµÄphpѧϰ֮·£¬
¼Æ»®ÔÚδÀ´µÄÒ»¶Îʱ¼äÄÚ£¬ÓÃ×ã¹»¶àµÄʱ¼äºÍ¾«Á¦À´Ñ§Ï°Á˽âphp¡£
×öµ½¾«Í¨Àí½â»¹ÓоÍÊÇ×Ô¼º¶ÀÁ¢µÄ¿ª·¢³öһϵÁеÄÍøÕ¾£¬×÷Ϊ¶Ô×Ô¼ºÑ§Ï°µÄ¼ìÑé¡£
×öºÃ¼¼Êõ×ܽáºÍ¼¼ÊõÄÚºËÀí½â ......