Phalcon 和 Laravel 的效率还是差很多的。

2016-07-21

一直很喜欢Laravel的项目结构设计,很喜欢它和rails的控制台工具。但是项目中一直在用Phalcon,无他,简单、熟悉了。而且,性能上确实非常非常好!

看了很多评测的,今天抽空自己做了一点点测试,看的结果更加直观:

环境:Mac、PHP7.0.8、Phalcon 2.1.0RC、Larave 5.2.40

程序:

Laravel使用默认环境,创建一个Index控制器,一个index方法,显示一行文字。使用optimize优化了。

Phalcon由于没有使用脚手架工具创建项目,自己手工搭建一下,主要就是创建路由、定义视图、挂载模板引擎(volt),将这些注入到di中,同样一个控制器,一个方法,显示同样的模板。

测试:ab -c 10 -n 1000 http://pails.xueron.com/ ,其中c是并发,n是请求总次数。调整两个参数,反复测试。

结果:

基本上laravel的rps(Requests per second)一直在25~40之间。一般为30多点。

而Phalcon的rps基本保持在500+,在500~650之间。

差太多啊~

 做了比较详细的测试:http://xwsoul.com/posts/1071,可以看到,效率主要差在stat/lstat/open/access这些文件的查找与打开上面了。看过Laravel的源码,在依赖注入的设计上面很精巧,但是也带来的问题,就是加载、反射、反复查找~, 效率牺牲的可不是一点半点。

所以打算做个小项目,就是为Phalcon弄一个简单的架子,什么di的服务、配置等等弄弄好,这样用phalcon建项目easy一点……

测试结果:

php-fpm运行larave的情况,可以看到时间耗用和CPU的占用都挺大:

ab测试结果:

下面是Phalcon的情况,好很多:

ab测试的结果:

 

好久不更新了,动弹一下……

2016-03-16

使用Docker,PHP7,重新构建了一下本站,速度提高没提高不知道……

下一步,使用PHP7+Phalcon(2.1.x)……

下一步,使用Ruby……

下一步,产品……

PhalconPHP and PHP7

2016-03-16

From: http://phalcon.io/phalconphp-and-php7

PHP7 was released on the 3rd of December, 2015. This new version brought forward a large number of new and exiting features (http://php.net/manual/en/migration70.new-features.php) to PHP. Perhaps one of the biggest of the new features is a new Zend Engine (the engine that powers PHP).

This new engine, code named PHPNG, will give some of your applications double the performance speed.

Some benchmarks that have been run so far:

WordPress 3.6 – 20.0% gain (253 vs 211 req/sec)
Drupal 6.1 – 11.7% gain (1770 vs 1585 req/sec)
Qdig – 15.3% gain (555 vs 482 req/sec)
ZF test app – 30.5% gain (217 vs 166 req/sec)
It is only natural that once it came out the PhalconPHP community was dying to know when we would get a chance to work with PhalconPHP and PHP7.

The Problem

We all know that PhalconPHP is written in Zephir starting with version 2.0, and that this language compiles its code into a C PHP Extension. Because of PHP7’s new engine the extension had to be rewritten and adapted to the new specifications.

The Solution

Knowing this, the PhalconPHP team started working since last year on an updated version of Zephir to make the compiled code work with PHP7.

After a few months we are finally delivered PhalconPHP 2.1 and Zephir 0.9.x which brings PHP7 support.

Installing PhalconPHP with PHP7

You will need to install PHP7+ and Zephir 0.9.2a-dev (or its latest branch). After you have them installed go to PhalconPHP 2.1.0+ branch and download the source code.

Installation example:

If you get these warnings ignore them:

That’s it!

You now have PhalconPHP and PHP7 working.

Can you expect PhalconPHP to be even faster? No, but you can expect to see your your app be much faster since your PHP code will run better with the new engine. Plus, you won’t have any overhead since PhalconPHP is a extension. The best part of all this is that you get all the new features that PHP7 brings to the table.

Do take into account that PHP7 is still rather new, and most of the commonly used extensions like memcache, memcached, and redis are available in Dev/Beta branches, so you need to reinstall them.

Best of luck to all and enjoy PhalconPHP + PHP7.

Phalcon 连接数据库中文字符集的问题

2014-08-11

网上的方法都是在配置里面添加charset,结果我苦逼的调试了好一会。

后来才发现我的php版本是5.3.3的,这样是不行滴!

5.3.6 Prior to version 5.3.6, charset was ignored.

PHP网站改版了,5.3.x要结束了。。。

2013-07-12

 

 

新版:2013-07-12_091813

 

 

旧版留念:2013-07-12_091830

坑爹的百度啊!

2012-10-27

今天写PHP,偶遇一个错误:called without object from outside a class ,于是百度查看一下详情,结果,度娘将所有网站报这个错误的都给我抓回来了。

看人家google,就知道俺想找啥么。