是否有必要缩小PHP? [英] Is there a point to minifying PHP?

查看:93
本文介绍了是否有必要缩小PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以缩小PHP,但是我想知道是否有任何意义. PHP是一种解释型语言,因此运行速度会比编译语言慢一些.我的问题是:客户会在页面加载中看到明显的速度改进吗?例如,如果我要减少PHP的话?

I know you can minify PHP, but I'm wondering if there is any point. PHP is an interpreted language so will run a little slower than a compiled language. My question is: would clients see a visible speed improvement in page loads and such if I were to minify my PHP?

还有,有没有办法编译PHP或类似的东西?

Also, is there a way to compile PHP or something similar?

推荐答案

将PHP编译为字节码,然后将其解释为类似于VM的内容.许多其他脚本语言也遵循相同的通用过程,包括Perl和Ruby.它不是像BASIC这样的传统解释语言.

PHP is compiled into bytecode, which is then interpreted on top of something resembling a VM. Many other scripting languages follow the same general process, including Perl and Ruby. It's not really a traditional interpreted language like, say, BASIC.

如果您尝试缩小"源,则不会有效提高速度.通过使用字节码缓存(如APC),您将获得大幅度的增长.

There would be no effective speed increase if you attempted to "minify" the source. You would get a major increase by using a bytecode cache like APC.

Facebook引入了名为 HipHop 的编译器,该编译器将PHP源代码转换为C ++代码. PHP大佬之一Rasmus Lerdorf在今年早些时候为Digg做了演示,其中涵盖了性能HipHop提供的改进.简而言之,它并没有比优化代码和使用字节码缓存更快.对于大多数用户来说,HipHop实在是太过分了.

Facebook introduced a compiler named HipHop that transforms PHP source into C++ code. Rasmus Lerdorf, one of the big PHP guys did a presentation for Digg earlier this year that covers the performance improvements given by HipHop. In short, it's not too much faster than optimizing code and using a bytecode cache. HipHop is overkill for the majority of users.

Facebook最近还发布了 HHVM ,这是一种基于他们工作的新虚拟机制作HipHop.它仍然是相当新的,尚不清楚是否会为公众带来重大的绩效提升.

Facebook also recently unveiled HHVM, a new virtual machine based on their work making HipHop. It's still rather new and it's not clear if it will provide a major performance boost to the general public.

只需确保明确说明,请完整阅读该演示文稿.它指出了使用 xdebug

Just to make sure it's stated expressly, please read that presentation in full. It points out numerous ways to benchmark and profile code and identify bottlenecks using tools like xdebug and xhprof, also from Facebook.

这篇关于是否有必要缩小PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆