stanley-king hace 8 años
padre
commit
1e0770fd98

+ 11 - 4
core/framework/db/mysqli.php

@@ -17,7 +17,7 @@ class Db
 	private static $iftransacte = true;
 
 	private static $connect_time = 0;
-	const reconnect_time = 10;
+	const reconnect_time = 3600;
 
 	private function __construct()
 	{
@@ -143,10 +143,17 @@ class Db
 	 * @param string $sql
 	 * @return bool/null/array
 	 */
-	public static function getAll($sql, $host = 'slave'){
+	public static function getAll($sql, $host = 'slave')
+    {
+        perfor_start();
 		self::connect($host);
-		$result = self::query($sql, $host);
-		if ($result === false) return array();
+        perfor_end("mysqli","connect");
+
+        perfor_start();
+        $result = self::query($sql, $host);
+        perfor_end("mysqli","query");
+
+        if ($result === false) return array();
 		$array = array();
 		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
 			$array[] = $tmp;

+ 22 - 6
core/framework/function/core.php

@@ -1565,7 +1565,8 @@ function halt($error){
  * @param string $content 待压缩的内容
  * @return string
  */
-	function compress_code($content) {
+function compress_code($content)
+{
     $stripStr = '';
     //分析php源码
     $tokens = token_get_all($content);
@@ -1635,7 +1636,8 @@ function get_obj_instance($class, $method='', $args = array())
  * @param int $type 1一维数组2二维数组
  * @return array
  */
-function array_under_reset($array, $key, $type=1){
+function array_under_reset($array, $key, $type=1)
+{
 	if (is_array($array)){
 		$tmp = array();
 		foreach ($array as $v) {
@@ -1700,6 +1702,7 @@ function rkcache($key, $callback = false)
  */
 function wkcache($key, $value, $expire = null)
 {
+    $start = microtime(true);
     if (C('cache_open')) {
         $cacher = Cache::getInstance('cacheredis');
     } else {
@@ -1709,7 +1712,9 @@ function wkcache($key, $value, $expire = null)
         throw new Exception('Cannot fetch cache object!');
     }
 
-    return $cacher->set($key, $value, null, $expire);
+    $ret = $cacher->set($key, $value, null, $expire);
+    perfor_period("wkcache",$start,$key);
+    return $ret;
 }
 /**
  * KV缓存 删
@@ -1719,6 +1724,7 @@ function wkcache($key, $value, $expire = null)
  */
 function dkcache($key)
 {
+    $start = microtime(true);
     if (C('cache_open')) {
         $cacher = Cache::getInstance('cacheredis');
     } else {
@@ -1728,7 +1734,9 @@ function dkcache($key)
         throw new Exception('Cannot fetch cache object!');
     }
 
-    return $cacher->rm($key);
+    $ret = $cacher->rm($key);
+    perfor_period("dkcache",$start,$key);
+    return $ret;
 }
 
 
@@ -1792,12 +1800,16 @@ function wcache($key = null, $data = array(), $prefix, $period = 0)
     	return false;
     }
 
+    $start = microtime(true);
     $period = intval($period);
     if ($period != 0) {
         $data['cache_expiration_time'] = time() + $period * 60;
     }
     $ins = Cache::getInstance('cacheredis');
-    return $ins->hset($key, $prefix, $data);
+    $ret = $ins->hset($key, $prefix, $data);
+    perfor_period("wcache",$start,$key);
+
+    return $ret;
 }
 
 /**
@@ -1812,8 +1824,12 @@ function dcache($key = null, $prefix = '')
     	return true;
     }
 
+    $start = microtime(true);
     $ins = Cache::getInstance('cacheredis');
-    return $ins->hdel($key, $prefix);
+    $ret = $ins->hdel($key, $prefix);
+    perfor_period("dcache",$start,$key);
+
+    return $ret;
 }
 
 /**

+ 2 - 2
core/framework/libraries/log.php

@@ -6,7 +6,7 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class Log
 {
-    const open_sql = true;
+    const open_sql = false;
     const SQL = 1;
     const INFO = 2;
     const DEBUG = 3;
@@ -17,7 +17,7 @@ class Log
 
     static $moduls = array("default","session");
 
-    const cur_level = self::INFO;
+    const cur_level = self::ERR;
 
     private static $log = array();
     private static $stsql_log = array();

+ 3 - 0
core/framework/libraries/model.php

@@ -698,7 +698,10 @@ class ModelDb
         if(is_mobile())
         {
             $sql = $this->buildSelectSql($options);
+            $start = microtime(true);
             $result = DB::getAll($sql,($options['lock'] === true || $options['master'] === true || defined('TRANS_MASTER')) ? 'master' : 'slave');
+            perfor_period("model",$start,"getAll");
+
             return $result;
         }
         else

+ 3 - 0
data/model/goods.model.php

@@ -78,7 +78,10 @@ class goodsModel extends Model
      */
     public function getGoodsList($condition, $field = '*', $group = '', $order = '', $limit = 0, $page = 0, $lock = false, $count = 0)
     {
+        $start = microtime(true);
         $condition = $this->_getRecursiveClass($condition);
+        perfor_period("goods.model",$start,"getGoodsList");
+
         return $this->table('goods')->field($field)->where($condition)->group($group)->order($order)->limit($limit)->page($page, $count)->lock($lock)->select();
     }
 

+ 1 - 1
helper/activity/full_sent.php

@@ -81,7 +81,7 @@ class full_sent
     {
         if($this->mFreePrice > 0) {
             $val = $this->mFreePrice / 100;
-            return "满{$val}包邮";
+            return "满{$val}元(专柜价)包邮";
         } else {
             return false;
         }

+ 3 - 0
helper/goods_helper.php

@@ -108,7 +108,10 @@ class goods_helper
 
     public function get_summary(&$goods_ids,&$related_goods)
     {
+        $start = microtime(true);
         $goods_list = Model('goods')->cls()->getGoodsOnlineList(array('goods_id' => array('in', $goods_ids)),self::fieldstr);
+        perfor_period("goods_helper",$start,"get_summary");
+
         $goods_ids = array();
         foreach ($goods_list as $goods) {
             $goods_id = intval($goods['goods_id']);

+ 6 - 0
mobile/control/control.php

@@ -140,7 +140,10 @@ class mobileControl
             if(empty($msg)) {
                 $msg = errcode::msg($code);
             }
+            $start = microtime(true);
             echo joutput_error($code, $msg, 'web') . "<br/>";
+            perfor_period("joutput",$start,"web");
+
             echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
             echo "性能关键统计:<br/><br/>";
             performance_helper::format_log();
@@ -193,7 +196,10 @@ class mobileControl
         else
         {
             echo 'success: return data=<br/>';
+            $start = microtime(true);
             joutput_data($data, 'web');
+            perfor_period("joutput",$start,"web");
+
             echo "<br/><br/>";
             echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
             echo "性能关键统计:<br/><br/>";

+ 2 - 0
mobile/control/index.php

@@ -27,8 +27,10 @@ class indexControl extends specialControl
     public function homeOp()
     {
         if($this->cur_page == 1) {
+            $start = microtime(true);
             $ret = $this->get_special(self::HomeSpecialID);
             $ret['mobile_page'] = mobile_page(2);
+            perfor_period("home",$start,"index");
 
             return self::outsuccess($ret,"shop/home");
         }

+ 6 - 0
mobile/control/special.php

@@ -36,13 +36,19 @@ class specialControl extends mobileHomeControl
 
     protected function get_special($special_id)
     {
+        $start = microtime(true);
         $helper = new special_helper($special_id);
         $specials = $helper->format($goods_ids);
+        perfor_period("special",$start,"get_special");
+
 
         if (!empty($goods_ids))
         {
+            $start = microtime(true);
             $helper = new goods_helper();
             $goodsex = $helper->get_summary($goods_ids, $related_goods);
+            perfor_period("special",$start,"get_summary");
+
 
             return array('special_list' => $specials,
                 'summary' => $goodsex['summary'],