成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Centos下10000次循環(huán)測試php對Redis和共享內(nèi)存(shm)讀寫效率

VPointer / 2676人閱讀

摘要:和還有共享內(nèi)存都是讀取內(nèi)存的數(shù)據(jù),為了測試一下到底效率誰更勝一籌,我在我的虛擬機下做了一次公平的測試。

redis和memcache還有共享內(nèi)存都是讀取內(nèi)存的數(shù)據(jù),為了測試一下到底效率誰更勝一籌,我在我的Centos虛擬機下做了一次公平的測試。

測試參數(shù)

環(huán)境:Centos (配置忽略)、語言:PHP、WebServer:Nginx、測試次數(shù):10000、字符類型及長度:字符串(1024)

準(zhǔn)備測試

 
  array ("id" => "4146","attacksdfdsfdsffffdffffdffffddd" => "5.45","atk_class" => "神圣級","wufang" => "4.9","def_class" => "超神級","cefang" => "4.9","mdf_class" => "超神級","hp" => "6.43","hp_class" => "神王級","dodge" => "55","dodge_class" => "SSSS","crit" => "50","crit_class" => "SSS","penetrate" => "55","penetrate_class" => "SSSS","mingzhong" => "51","hit_class" => "SSSS","anti_dizziness" => "0","anti_dizzinesssdfdsfdsfdsfdsfds_class" => "F","anti_critical" => "20","anti_critical_class" => "F","tenacity" => "0","tenacity_class" => "F",
  ),
  2 => 
  array ("id" => "414ddffff7","attack" => "5.45","atk_class" => "神圣級","wufang" => "4.95","def_class" => "超神級","cefang" => "4.95","mdf_class" => "超神級","hp" => "6.43","hp_class" => "神王級","dodge" => "55","dodge_class" => "SSSS","crit" => "50","crit_class" => "SSS","penetrate" => "55","penetrate_class" => "SSSS","mingzhong" => "51","hit_class" => "SSSS","anti_dizziness" => "0","anti_dizziness_clsdfdsfdsfdsfdsfdsass" => "F","anti_critical" => "20","anti_critical_class" => "F","tenacity" => "0","tenacity_class" => "F",
  ));

$str = json_encode($arr);
echo strlen($str);          //輸出1024

對redis進行10000次寫入測試

connect("127.0.0.1",6379);
$redis->auth("310c8cabcdefghf2d8abcdefd44496ac80");
$start = microtime(true) ;

for($i = 0; $i<10000; $i++) {
    $redis->set("key", $str);
}
echo microtime(true) - $start;    //執(zhí)行5次,大概平均結(jié)果為  1.7016470432281 秒

對共享內(nèi)存(shm)進行10000次寫入測試


對redis進行10000次讀測試

connect("127.0.0.1",6379);
$redis->auth("310c8cabcdefghf2d8abcdefd44496ac80");
$start = microtime(true) ;

for($i = 0; $i<10000; $i++) {
    $redis->get("key");
}
echo microtime(true) - $start;     //執(zhí)行5次,大概平均結(jié)果為 2.1236310005188 秒

對共享內(nèi)存(shm)進行10000次讀測試


結(jié)果清單

Redis 讀:2.1秒 寫:1.7秒

Shm 讀:0.0021秒 寫:0.0025 秒

可見,效果差別懸殊。

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/61997.html

相關(guān)文章

  • Centos10000循環(huán)測試phpRedis共享內(nèi)存(shm)讀寫效率

    摘要:和還有共享內(nèi)存都是讀取內(nèi)存的數(shù)據(jù),為了測試一下到底效率誰更勝一籌,我在我的虛擬機下做了一次公平的測試。 redis和memcache還有共享內(nèi)存都是讀取內(nèi)存的數(shù)據(jù),為了測試一下到底效率誰更勝一籌,我在我的Centos虛擬機下做了一次公平的測試。 測試參數(shù) 環(huán)境:Centos (配置忽略)、語言:PHP、WebServer:Nginx、測試次數(shù):10000、字符類型及長度:字符串(102...

    kamushin233 評論0 收藏0
  • swoole_table 實現(xiàn)原理剖析

    摘要:受限于的實現(xiàn),程序無法使用多線程進行編程開發(fā)。比如實現(xiàn)一個聊天室程序,用戶在進程中處理,用戶在進程中處理,和如果在同一個,這個在多線程環(huán)境中直接用表示,和加到對應(yīng)的中即可。想要解決這個問題,必須實現(xiàn)一個基于共享內(nèi)存的數(shù)據(jù)結(jié)構(gòu)。 Swoole項目從 2012 年推出到現(xiàn)在已經(jīng)有 5 年的歷史,現(xiàn)在越來越多的互聯(lián)網(wǎng)企業(yè)使用Swoole來開發(fā)各類后臺應(yīng)用。受限于 PHP 的ZendVM實現(xiàn),...

    smartlion 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<