Skip to Content
PHP编程:第4版
book

PHP编程:第4版

by Kevin Tatroe, Peter MacIntyre
January 2021
Intermediate to advanced
505 pages
9h 45m
Chinese
Publishing House of Electronics Industry
Content preview from PHP编程:第4版
338
15
应用技术
难阅读并要花更多时间去写。如果将时间花费在不会出问题的代码上,那是在浪费时间,
尤其是需要过一段时间后维护代码,而那些代码不再看得懂就更糟了。
一旦你的代码可以工作,你应该找出其中需要优化的地方。优化代码的目标通常为缩短
运行时间和减少内存占用。
在优化之前,问自己到底是否需要优化。太多的程序员都把时间花费在琢磨一系列复杂
的字符串函数调用是否比单独的
Perl
正则表达式更快上,虽然包含这个代码的页面
5
钟才被访问一次。只有在页面花费长时间加载并且用户感受到它慢的时候,优化才是必
需的。流行网站经常有这些症状——如果对某个页面的请求来得足够快,生成该页面的
时间之短可能意味着瞬间完成,时间之长则可能会导致服务器宕机。如果你的网站需要
漫长的等待,可以打赌你的用户会立即决定从其他网站获取信息。
一旦决定页面需要优化(通过一些终端用户测试和监测),你可以进而找出什么地方慢了。
你可以用本章后面“剖析”一节中讲述的技术来记录页面中各种子程序和逻辑单元的用
时。这将有助于你找到页面中哪些部分花费时间太长——这些部分是你需要集中优化的
地方。如果页面花费
5
秒生成,你不可能通过优化一个仅占用
0.25
秒的函数让它降低到
2
秒。找出最花费时间的代码并且专门对它进行优化。记录页面和需要优化部分的时间
以确保你的修改起的不是反作用。
最后,要知道何时停手。有时候你要运行的程序的速度是有绝对限制的。在这种情况下,
得到较好性能的方式是根据情况添置硬件。方案或许是升级到更快的机器或添加更多的 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez

Publisher Resources

ISBN: 9787121404634