跳到主要內容

發表文章

目前顯示的是 6月, 2017的文章

在CentOS 6.x 安裝Python 2.7 的方法

CentOS 6.x 是使用各種python 2.6 來運作, 比如yum 就是使用python 2.6, 倘若貿然升級到 2.7, 將會造成無法使用yum 的情況. 因為不可以覆蓋Python 2.6, 所以採用以下的方法: wget http://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz tar -zxvf Python-2.7.12.tgz cd Python-2.7.12 yum install openssl openssl-devel zlib-devel gcc -y ./configure --prefix=/usr/local --with-zlib make && make altinstall ln -s /usr/local/bin/python2.7 /usr/bin/python27 wget https://bootstrap.pypa.io/get-pip.py python get-pip.py ln -s /usr/local/bin/pip2.7 /usr/bin/pip27

解決atomic repo 的gpg key 太舊造成的問題 The GPG keys listed for the "CentOS / Red Hat Enterprise Linux 6 - atomicrocketturtle.com" repository are already installed but they are not correct for this package

wget https://www.atomicorp.com/RPM-GPG-KEY.atomicorp.txt mv RPM-GPG-KEY.atomicorp.txt /etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt

PHP 7.1.5 require() vs include() vs spl_autoload() vs require_once() vs include_once() benchmark

做了數次的測試, include 相對穩定與快速一些.  很多時候 require 與 include 不相上下 spl_autoload 則令人失望, 速度非常不穩定而且比require(), include() 慢.  如果要使用spl_autoload, 建議在裡面搭配 require() / include() 比較好. spl_autoload 的唯一好處就是自動載入需要的檔案, 不需要再在include/require, 避免在不同的class / php 裡因為需要而要重新include/require, 從而減少浪費與增加載入速度.  不過, 若是在相同的條件下, include / require 全部一樣的檔案, spl_autoload 則失去優勢了.  如以下的測試. 另外, 有開啟opcache 確實會比較快, 建議還是打開的好, 畢竟opcache 是將之前compile好的php 放在memory, 下一次再用時就不需要再compile, 從而達到快速載入的時間 With opcache enabled (Require 1 files) Execution Time: 0.012760877609253 seconds. (Require 3 files) Execution Time: 0.0004780292511 seconds. (Require 5 files) Execution Time: 0.00022292137145996 seconds. (Require 50000 files) Execution Time: 7.2010669708252 seconds. (Require 50000 files) Execution Time: 1.4862420558929 seconds. (Require 100000 files) Execution Time: 8.5520980358124 seconds. (Require 100000 files) Execution Time: 2.9480040073395 seconds. (Include 1 files) Execution Time: 7.6055526733398E...