摘要:和還有共享內(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
摘要:和還有共享內(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...
摘要:受限于的實現(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),...
閱讀 3892·2021-09-23 11:51
閱讀 3071·2021-09-22 15:59
閱讀 873·2021-09-09 11:37
閱讀 2074·2021-09-08 09:45
閱讀 1269·2019-08-30 15:54
閱讀 2068·2019-08-30 15:53
閱讀 495·2019-08-29 12:12
閱讀 3292·2019-08-29 11:15