PHPã¨Pythonã¨Rubyã®é£æ³é åã®ãã¼ã¿æ§é ãåææã«åãæ¹éã§æ§è½æ¹åããã¦ã話
PHPã¨Pythonã¨Rubyã®é£æ³é åã®ãã¼ã¿æ§é ããããã4ã5å¹´ã»ã©åã«è¦ç´ããããã³ããã¼ã¯ãã¹ãã«ãã£ã¦ã¯å以ä¸éããªã£ãã¨ãããã¨ãããã¾ãããå ·ä½çã«ã¯ä»¥ä¸ã®ãã¼ã¸ã§ã³ã§å®è£ ã®å¤§å¤æ´ãããã¾ããã
- PHP 7.0.0 HashTableé«éå (2015/11)
- Python 3.6.0 dictobjecté«éå (2016/12)
- Ruby 2.4.0 st_tableé«éå (2016/12)
ãããã®ãã¼ã¿æ§é ã¯ã¦ã¼ã¶ã¼ã®å©ç¨ããé£æ³é åã ãã§ãªãè¨èªã®ã³ã¢ã§ãå©ç¨ããã¦ããã®ã§ãè¨èªå ¨ä½ã®æ§è½æ¹åã«è²¢ç®ãã¦ãã¾ã1ã
ã¹ã¯ãªããè¨èª3ã¤ãåææã«åããã¼ã¿æ§é ã®æ¹åã«åãçµãã ã ãã§ãé¢ç½ãç¾è±¡ã§ãããããã«é¢ç½ããã¨ã«åå®è£ ã®æ¹éã¯é常ã«ä¼¼ã¦ãã¾ããç¬ç«ã«æ¹åã«åãçµãã ã®ã«åãçµè«ã«è³ã£ãã¨ããã°èå³æ·±ãå¶ç¶ã¨è¨ããã§ããã2ã
æ¬ç¨¿ã§ã¯3è¨èªã®é£æ³é åã®å¾æ¥å®è£ ã¨æ°å®è£ ã®æ¦è¦ã説æããä¸ã§ãæ°å®è£ ãéããªãã«ã©ã¯ãªã«ã¤ãã¦ç§ãªãã«è§£èª¬ãã¦ã¿ã¾ãã
æåã«ãæããã¦ããã¨ãæ¬æ°ãªããã·ã¥å®è£ ãçºæããããããªè©±ã§ã¯ããã¾ãããå°éãªæ¹åã¨æããæ¹ãå®ç¶ã«è¿ãã¨æãã¾ãã
PHPã»Pythonã»Rubyã®æ°æ§å®è£ ã®æ¦è¦
åè¨èªã®é£æ³é åã®ãã¼ã¿æ§é ãã©ãå¤ãã£ãã®ãè¦ã¦ãããã¨ã«ãã¾ãããã次ã®å³ã¯PHP5ã®é£æ³é åã®ãã¼ã¿æ§é ã§ãã
ããã¯ã¢ã«ã´ãªãºã ã®æç§æ¸ã«ãè¼ã£ã¦ãããããªé£æ³é åã®å®è£ ããã§ã¤ã³æ³ãã®ç´ ç´ãªå®è£ ã«ãªã£ã¦ãã¾ãããã¼ã«å¯¾å¿ããããã·ã¥å¤ãè¨ç®ããããã·ã¥å¤ãã¨ã«ãã¼ã¨å¤ã®çµãæ ¼ç´ãã¾ããããããã®å¤ã¯é£çµãªã¹ãã§ç®¡çããã¦ãã¾ãã
ãããæ¹åãããã®ãPHP7ã®å®è£ ã§ãã
ããã¯ãã§ã¤ã³æ³ã®å¤å½¢ã®å®è£ ã¨æãããã¨ãã§ãã¾ããå段ã®é åã¯PHP5ã§ã¯ãã¤ã³ã¿ã®é åã§ããããPHP7ã§ã¯æ·»åã®é åã«ãªãã¾ãããã¾ããã¼ã¨å¤ã®çµã¯ããã¾ã§1è¦ç´ ãã¨ã«åçã«ç¢ºä¿ãã¦ããã®ãPHP7ã§ã¯ãããããé åã確ä¿ããä¸ã§æ·»åãã¼ã¹ã§é£çµãªã¹ããå®ç¾ãã¦ãã¾ãã
次ã«Pythonãè¦ã¦ããã¾ããããPython 3.5ã¾ã§ã®é£æ³é åã®å®è£ ã¯æ¬¡ã®ãããªãã®ã§ããã
ããã¾ãæç§æ¸éãã®é£æ³é åã®å®è£ ã§ãããªã¼ãã³ã¢ãã¬ã¹æ³ãã¨å¼ã°ããæ¹å¼ã§ãããã¼ã¿æ§é ã¨ãã¦ã¯é å1åã®ã¿ã®ã·ã³ãã«ãªä»çµã¿ã§ãããããã·ã¥å¤ãè¡çªããå ´åã¯æ±ºã¾ã£ãã«ã¼ã«ã§è¦ç´ ã辿ã£ã¦ããå¿ è¦ãããã¾ãã
Python 3.6ã§ã¯ããã«æ¹åãå ãã¦ãã¾ãã
ããã¯ãªã¼ãã³ã¢ãã¬ã¹æ³ã®å¤å½¢ã«ãªã£ã¦ãããæ·»åã管çããé åã¨è¦ç´ ã管çããé åã®2段æ§ãã«ãªã£ã¦ãã¾ããè¡çªããå ´åã®ã«ã¼ã«ãªã©ã¯Python 3.5以åã¨å ¨ãåãã§ãã
Rubyã«ã¤ãã¦ã¯æ§å®è£ ãPHP5ã«è¿ããæ°å®è£ ã¯Python 3.6ã«ä¼¼ã¦ããã¨ããèªèã§ã3ã
ãªãéããªãã®ãï¼
PHP7ã¨Python3.6ã®é£æ³é åã®ãã¼ã¿æ§é ãè¦ãã¨ããã¼ã¿ã®æã¡æ¹ãé常ã«ä¼¼ã¦ããã®ããããã¨æãã¾ããè¡çªè§£æ±ºã®æ¹éãç°ãªã£ã¦ããã ãã§ã2段æ§ãã®å段ã®é åã§æ·»åã管çããç¹ãå¾æ®µã®é åã¯æ ¼ç´é ã«è¦ç´ ã追å ãã¦ããç¹ãªã©ã¯å®å ¨ã«åãã§ãã
ããã«ãã¦ãããªãããã§éããªãã®ã§ãããããåçã«è¨ç®éãæ¹åãããããªå¤æ´ã§ã¯ããã¾ããããPythonã«ã¤ãã¦ã¯éæ¥åç §ã1åå¢ãã¦ããã®ã§ä¸å©ã«ãªã£ã¦ãããããããã¾ããã
æ§è½æ¹åã¯è¤æ°ã®è¦å ã絡ã¿åã£ãçµæã§ããã¢ããªã±ã¼ã·ã§ã³ã«ãä¾åããã®ã§ãä¸æ¦ã«ããã®ç¹ãæ§è½æ¹åã«å¯ä¸ãããã¨ã¯è¨ããªãã®ã§ãããç§ã¯æ°å®è£ ã®ãã¢ã¯æ¬¡ã®2ç¹ã ããã¨èãã¦ãã¾ãã
- ãã¼ã¿ãµã¤ãºã®æ¸å°ãã¡ã¢ãªã®åç §å±ææ§ã®åä¸
- é£æ³é åã®æ§ç¯æã«é£ç¶ããã¡ã¢ãªé åã«ã·ã¼ã±ã³ã·ã£ã«ã«æ¸ãè¾¼ã¾ããç¹
è¦ã¯ã¡ã¢ãªã®èªã¿æ¸ãã«é¢é£ããæ¹åãæ¯é çã ã£ãã®ã§ã¯ãªããï¼ã¨ãããã¨ã§ããé«ç´è¨èªã使ã£ã¦ããã¨ã¤ãå¿ããã¡ã§ãããç¾ä»£ã®CPUããè¦ãã¨ã¡ã¢ãªã¯é常ã«é ãã®ã§ãã
ãã£ãã·ã¥ãããçãé«ããæ¹ãæå©ã¨ãã話
ã¡ã¢ãªãCPUã¨æ¯ã¹ã¦ã©ããããé ãã®ããIntelã®è³æ4ããèªã¿åã£ãæ°åãç´¹ä»ãã¾ãã
- L1ãã£ãã·ã¥ããã 4 Clock
- L2ãã£ãã·ã¥ããã 10 Clock
- L3ãã£ãã·ã¥ããã 40 Clock
- ãã£ãã·ã¥ãã¹ 200ã330 Clock
ãã£ãã·ã¥ãã¹ãèµ·ããã¨æ°ç¾ã¯ããã¯ã®ã¡ã¢ãªã¹ãã¼ã«ãçºçããã¨ããã®ã¯æãããæ°åã§ããããã¾ããä¸ä½ã®ãã£ãã·ã¥ãã¾ãã¾ãé ããã¨ããããã¾ããã§ããããç¾ä»£ã®CPUã§ã¯ããã«ãã£ãã·ã¥ãããçãé«ããããéè¦ã«ãªãã¾ããæ±ããã¼ã¿ãµã¤ãºãå°ããã§ããã°ãã®åã¡ã¢ãªã¢ã¯ã»ã¹ãæ¸ãã¯ãã§ãããåæã«ä½¿ããããã¼ã¿ãã§ããã ãè¿ãã«æ ¼ç´ããã°ãã£ãã·ã¥ãããçãã¢ããããã¯ãã§ã5ã
PHPã«ã¤ãã¦è¨ãã°æ§å®è£ ã§ã¯ã¡ã¢ãªå©ç¨ã«ç¡é§ãå¤ãã£ãã®ããæ°å®è£ ã«ãªã£ã¦1è¦ç´ ãããã®ã¡ã¢ãªä½¿ç¨éãåå以ä¸ã«ãªã£ã¦ãã¾ãï¼72ãã¤ãâ32ãã¤ãï¼ãRubyãPHPã»ã©ã§ã¯ããã¾ãããããã¤ã³ã¿ã¢ã¯ã»ã¹ãå»ãããã¨ã§ç¹ã«64bitç°å¢ã§ã¡ã¢ãªä½¿ç¨éãåæ¸ã§ãã¦ãã¾ã6ãã¾ãPythonã¯ããã¾ã§ãã¼ã¿ã®ééãå¤ãã£ã7ã®ã«å¯¾ããæ°å®è£ ã§ã¯è¦ç´ ã®é åãå¯ã«ä½¿ããããã«ãªãããµã¤ãºã®å°ããå段ã®æ·»åé åã ããçã«ãªãããã«å¤ãã£ã¦ãã¾ããããããæ§è½æ¹åã«å¤§ããè²¢ç®ãã¦ããã¨ããã®ã¯ç´æçã«ãããããªã話ã ã¨æãã¾ãã
ã¡ã¢ãªã®ã·ã¼ã±ã³ã·ã£ã«ã¢ã¯ã»ã¹ã¯æå©ã¨ãã話
æ¹åè¦å ã®2ç¹ç®ã«æãããé£æ³é åã®æ§ç¯æã«é£ç¶ããã¡ã¢ãªé åã«ã·ã¼ã±ã³ã·ã£ã«ã«æ¸ãè¾¼ã¾ããç¹ãã«ã¤ãã¦ã¯è£è¶³ãå¿ è¦ããããã¾ããã
å¤ãããã°ã©ãï¼ç§ãå«ãï¼ã®å¸¸èã¨ãã¦ãé£æ³é åã¯ååã¨ãã¦æ ¼ç´é ãä¿æããªãã¨ããã®ãããã¨æãã¾ããããããä»åç´¹ä»ããæ°å®è£ ã®å¾æ®µãè¦ç´ ãæ ¼ç´ããé åã¯æ·»åã®å°ããæ¹ããé ã«ä½¿ã£ã¦ãããã¨ã«ãªãã®ã§ãèªç¶ã«å®è£ ããã°åæã«æ ¼ç´é ãä¿æããã¾ãããããå©ç¨ãã¦Python 3.7ããã¯é£æ³é åã®è¦ç´ ã®é åºä¿æãä»æ§ã«ãªã£ã¦ãã¾ãã
ç§ã®æè¦ã¯ããã®å®è£ ãæ©è½é¢ã ãã§ãªãæ§è½é¢ã§ãã¡ãªãããçãã§ããã®ã§ã¯ãªããï¼ã¨ãããã¨ã§ãã
Pythonã®æ§å®è£ ãèããã¨ãè¤æ°ã®è¦ç´ ãæã¤é£æ³é åãæ§ç¯ããéã®ã¡ã¢ãªæ¸ãè¾¼ã¿ã¯ã©ã³ãã ã¢ã¯ã»ã¹ã«ãªã£ã¦ãã¾ãããä¸æ¹ãæ°å®è£ ã§ã¯ã·ã¼ã±ã³ã·ã£ã«ãªã¢ã¯ã»ã¹ã«ãªãã¾ããæè¿ã®CPUã§ã¯é£ç¶ããã¡ã¢ãªé åã®ã¢ã¯ã»ã¹ã«å¯¾ãã¦ãã¼ãã¦ã§ã¢ããªãã§ããã£ã¼ããããªã«åãã¦ã¢ã¯ã»ã¹ããããªã¡ã¢ãªé åãåæã«ãã£ãã·ã¥ã«ä¹ãã¦ãããã®ã§ãã©ã³ãã ã¢ã¯ã»ã¹ããã·ã¼ã±ã³ã·ã£ã«ã¢ã¯ã»ã¹ã®æ¹ãæå©ãªã®ã§ãã
ã¹ã¯ãªããè¨èªã§ã¯è¨èªã³ã¢ã§ãé£æ³é åãå¤ç¨ãããããé£æ³é åã®æ§ç¯ãé »ç¹ã«è¡ããã¾ããã¤ã¾ããé£æ³é åã®æ§ç¯ã³ã¹ããä¸ããããã°æ§è½é¢ã¸ã®å¯ä¸ã¯å¤§ããããã«æãã¾ãããããããã¾ã§æ¯é çãªè¦å ã«ãªãã®ãã¯æ£ç´ãªã¨ãããããã¾ããããå¯è½æ§ã¨ãã¦ã¯ååããããããã«æãã¾ãã
è½ç©æ¾ã
ä»åã¹ã¯ãªããè¨èª3ã¤ã®é£æ³é åã®å®è£ ã®çµç·¯ã調ã¹ã¦ã¿ãã®ã§ãããå½±é¿ãã¼ãã¨ã¯è¨ããªãã«ãããçµæçã«å®è£ ãä¼¼ããããªé¨åãããããã§ããä¸æ¹ã§ãå®è£ ææãè¿ãç¹ã«ã¤ãã¦ã¯OSã»CPUã®64bitåãé¢ä¿ãã¦ããããããã¾ããã2010å¹´é ãã64bitç°å¢ãä¸è¬çã«ãªã£ã¦64bitãã¤ã³ã¿ãæ§è½é¢ã®è¶³ããã«ãªããããªç¶æ³ãåå¥ã«è¡¨é¢åããçµæã¨ãã¦åææã«æ¹åãããã¨ããã®ã¯ãããã話ã§ãï¼ããããå æé¢ä¿ã¯å¾ããå¤æããã®ãé£ããé¨åãããã¾ããâ¦ï¼ã
æ¬ç¨¿ã§ã¯3è¨èªã®é£æ³é åã®å®è£ ãé常ã«ä¼¼ã¦ããã¨ãã話ããã¦ãã¾ããããç´°ããç¹ã¯ããªãç°ãªã£ã¦ãã¾ããPHPã§ã¯å段ã®æ·»åã管çããé åã«32bitæ´æ°ã使ã£ã¦ãã¾ãããPythonã¨Rubyã§ã¯é£æ³é åã®ãµã¤ãºãå°ããã¨ãã«æ·»åã8bitæ´æ°ã®é åã§ç®¡çãã¦ã¡ã¢ãªæ¶è²»ãæãã工夫ãè¦ããã¾ããã¹ã¯ãªããè¨èªã§ã¯å°ãããµã¤ãºã®é£æ³é åã大éã«ä½¿ãå¾åãããã®ã§ããã®ãããªæé©åã¯åççãªã®ã§ããããããã¯PHPã§ãæ¡ç¨ã®ä½å°ãããããã§ãã
é£æ³é åã®å®è£ ã¨ãã¦ãã§ã¤ã³æ³ã¨ãªã¼ãã³ã¢ãã¬ã¹æ³ã®ã©ã¡ããåªãã¦ãããã«ã¤ãã¦ã¯ä½ã¨ãè¨ããªãã¨ããã§ããRubyããã§ã¤ã³æ³ãããªã¼ãã³ã¢ãã¬ã¹æ³ã«ä¹ãæãã¦ããã®ã§ãå®ã¯ãã¡ãã®æ¹ãææã¨ãããã¨ãªã®ããããã¾ããããã ãçµæçã«ããã ãä¼¼ãå®è£ ã«ãªã£ã¦ãã¾ãã¨ä¸¡è ã§å¤§å·®ãªãã¨ããå¯è½æ§ãããããã§ãã
è½ç©æ¾ã2ï¼è¿½è¨ï¼2020-01-11ï¼
@_ko1ããï¼Rubyã³ã¢ã³ããã¿ã¼ï¼ããããRuby 2.4ã®å®è£ æã¯PHPã¨Pythonã®å®è£ ãèªèãã¦ãããã¨ã®ãã¨ãå®å ¨ã«ç¬ç«ãªå®è£ ã¨ã¯è¨ããªãããã§ãã
ããã¯rubyã§ã¯ä»è¨èªãæèããå¤æ´ã§ã https://t.co/YKQzTajqCc
— _ko1 (@_ko1) January 10, 2021
確ãã«ãå½æã®è°è«ã確èªããã¨Pythonã®æ§å®è£ ãããªãåèã«ãã¦ã¾ããããã ãPython 3.6ã¨ã»ã¼åææã«å®è£ ãè¡ããã¦ããã®ã§ãå¶ç¶ã®ä¸è´ã®é¨åãå¤å°ããããã«æãã¾ããã
@methaneããï¼Pythonã³ã¢ã³ããã¿ã¼ãPython 3.6ã®dictæ¹åã®å®è£ è ï¼ããããPython 3.6ã®å¤æ´ã¯æ¿å ¥é ã®ç¶æã主ç®çãã¡ã¢ãªä½¿ç¨éåæ¸ã¯ã¡ãªããã ãæ§è½é¢ã§ã¯ããã¾ã§å¤§ããªã¤ã³ãã¯ãã¯ãªããããã¨ã®ãã¨ã
ãã£ã±ãè¨æ£ã主ç®çã¯ããæ¿å ¥é ã®ç¶æãæ§dictã«å¯¾ãã¦ãªã¼ãã¼ããããã»ã¨ãã©ãªãããã«å®ç¾ãããã¨è¨ã£ãæ¹ãèæ¯ã¨ãã¦æ£ç¢ºã§ããã
— Inada Naoki (@methane) January 11, 2021
ãã¾ãã§ã¡ã¢ãªä½¿ç¨éåæ¸ãçæã¨ã¤ãã¬ã¼ãã®é«éåãã¤ãã¦ãããããå¾ã https://t.co/oYbpbDGv0j
ããããªãããã¿ã¤ãã«ãåã§ãããâ¦ã確ãã«Pythonã®æ§å®è£ ã¯ä½è¨ãªãã¤ã³ã¿åç §ããªãã®ã§64bitç°å¢ã§ãä¸å©ãããªãããªã¼ã¨ã¯æã£ã¦ã¾ããã
ã¾ã¨ã
PHPãPythonãRubyã®é£æ³é åã®æ§è½ããã³ã¡ã¢ãªå¹çã2015ã2016å¹´ããã«æ¹åããããããã®å®è£ ãä¼¼ã¦ããã¨ãã話ãç´¹ä»ãã¾ãããã¾ããæ§è½æ¹åã®è¦å ã¯ã¡ã¢ãªã®èªã¿æ¸ãã«é¢é£ãããã®ã§ã¯ãªããï¼ã¨ããç§ã®æè¦ãç´¹ä»ãã¾ããã
3ã¤ã®å®è£ ãä¼¼ã¦ããã¨ããææã¯ãã¾ãè¦ããã¨ããªãã®ã§è¨äºã«ã¾ã¨ãã¦ã¿ã¾ããããä»ã®è¨èªã§ããããçä¼¼ãã¹ããã¨ãã話ããããããã§ã¯ããã¾ããã3è¨èªã¨ãåè¨èªã使ã£ããã³ããã¼ã¯ãã¹ããå®æ½ããä¸ã§æ°å®è£ ãæ¡ç¨ããããã§ããããå¥ã®è¨èªã»å¥ã®ã¢ããªã±ã¼ã·ã§ã³ã§ãæé©ãªãã¼ã¿æ§é ã¨ã¯éãã¾ããã大äºãªã®ã¯ãæ¨æ¸¬ãããªãè¨æ¸¬ãããã§ãããã
æ§è½æ¹åã®è¦å ã«ã¤ãã¦ã¯ç§ã®å¦æ³ã®é¨åãå¤åã«ããã¨æãã¾ãããPythonã¨Rubyã«ã¤ãã¦ã¯ä»åããã£ã¨ã½ã¼ã¹ã³ã¼ããçºããç¨åº¦ãªã®ã§è´å½çãªééããããããããã¾ãããèè ã®æ¹ã®ããã³ãããå¾ ã¡ãã¦ããã¾ãã
åèURL
-
Pythonã®å®è£ å¤æ´ã¯æ§è½é¢ã®ã¡ãªããã¯å°ããã£ãã¨ããææããããã¾ãããæ¬ç¨¿ãè½ç©æ¾ã2ããåç §ã®ãã¨ã↩
-
Rubyã®å®è£ ã§ã¯ä»ã®å®è£ ãæèãã¤ã¤éçºãã¦ããããã§ããæ¬ç¨¿ãè½ç©æ¾ã2ããåç §ã®ãã¨ã↩
-
https://github.com/ruby/ruby/blob/master/st.c ã®ã³ã¡ã³ãé¨ã«æ°å®è£ ã®èª¬æãæ¸ãã¦ããã¾ãã↩
-
Performance Analysis Guide for Intel® Core⢠i7 Processor and Intel® Xeon⢠5500 processorsãã↩
-
ã¡ã¢ãªãã£ãã·ã¥ã¯64ãã¤ããªã©ã®ãã£ãã·ã¥ã©ã¤ã³ãµã¤ãºåä½ã§ãã£ãã·ã¥ãããããã1ãã¤ãã¢ã¯ã»ã¹ãããå¨å²ã®64ãã¤ãã®ã¢ã¯ã»ã¹ãã¿ãã¿ãããªããã§ã↩
-
Ruby2.3以åã¯è¦ç´ ã®ãã§ã¤ã³ãåæ¹åé£çµãªã¹ãã§ç®¡çãã¦ããç¹ãä¸å©ã ã£ãããã«æãã¾ã↩
-
ãªã¼ãã³ã¢ãã¬ã¹æ³ã§ã¯è¡çªé »åº¦ãä¸ããããã«ããã·ã¥ãã¼ãã«ãµã¤ãºã大ããã«åãå¿ è¦ããããæç§æ¸çå®è£ ã ã¨ã¡ã¢ãªãé£ã³é£ã³ã«ä½¿ããã¨ã«ãªããã↩