php-fpm框架和swoole框架性能对比
环境
deepin15.11、php7.2.9、nginx1.16.1、mysql5.7、ab2.3
对比框架
FPM框架:laravel6 ,swoole框架:easyswoole3、golang1.14.2
对比维度
1:单次计算能力
php-cli
<?php
$stime = microtime(true);
for ($a=1;$a<=1000;$a++){
for ($b=1;$b<=1000;$b++){
for ($c=1;$c<=1000;$c++){
if ($a == $b && $b==$c){
}
}
}
}
$etime = microtime(true);
$ret = bcsub($etime,$stime,4);
var_dump($ret);
golang
func main() {
start :=time.Now()
for a:=1; a<=1000 ; a++ {
for b:=1; b<=1000;b++ {
for c:=1;c<=1000 ;c++ {
if a== b&& b==c {
//fmt.Println(a*c*c)
}
}
}
}
end := time.Now().Sub(start)
fmt.Println(end)
}
执行结果:
php-cli:13.5324 s
golang:314.06603ms
2:并发下计算能力
ab -c 100 -n 10000 执行计算,循环1000000次
easyswoole:Time taken for tests: 47.550 seconds
golang:Time taken for tests: 1.337 seconds
3:操作数据库
//easyswoole
$model = new UserModel();
$model-