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

資訊專欄INFORMATION COLUMN

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

kamushin233 / 1236人閱讀

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

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

測(cè)試參數(shù)

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

準(zhǔn)備測(cè)試

 
  array ("id" => "4146","attacksdfdsfdsffffdffffdffffddd" => "5.45","atk_class" => "神圣級(jí)","wufang" => "4.9","def_class" => "超神級(jí)","cefang" => "4.9","mdf_class" => "超神級(jí)","hp" => "6.43","hp_class" => "神王級(jí)","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" => "神圣級(jí)","wufang" => "4.95","def_class" => "超神級(jí)","cefang" => "4.95","mdf_class" => "超神級(jí)","hp" => "6.43","hp_class" => "神王級(jí)","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

對(duì)redis進(jìn)行10000次寫入測(cè)試

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 秒

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


對(duì)redis進(jìn)行10000次讀測(cè)試

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 秒

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


結(jié)果清單

Redis 讀:2.1秒 寫:1.7秒

Shm 讀:0.0021秒 寫:0.0025 秒

可見,效果差別懸殊。

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

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

相關(guān)文章

  • Centos10000循環(huán)測(cè)試php對(duì)Redis共享內(nèi)存(shm)讀寫效率

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

    VPointer 評(píng)論0 收藏0
  • swoole_table 實(shí)現(xiàn)原理剖析

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

    smartlion 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

kamushin233

|高級(jí)講師

TA的文章

閱讀更多
最新活動(dòng)
閱讀需要支付1元查看
<