惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
V
V2EX - 技术
S
Secure Thoughts
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
S
Securelist
S
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
G
GRAHAM CLULEY
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
Intezer
Google Online Security Blog
Google Online Security Blog
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
The Cloudflare Blog
I
InfoQ
L
LangChain Blog
U
Unit 42
P
Proofpoint News Feed
S
Schneier on Security
S
Security Affairs
Y
Y Combinator Blog
T
Tenable Blog
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
量子位
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
AWS News Blog
AWS News Blog

风雪之隅

深入理解PHP7内核之OBJECT - 风雪之隅 PHP 8新特性之Attributes(注解) - 风雪之隅 博客迁移到腾讯云 - 风雪之隅 在Qcon 2015 北京上的演讲PPT - PHP7 Yar-2.1 新功能介绍 - 风雪之隅 Yaf and Phalcon, which is faster? HTTPOXY漏洞说明 - 风雪之隅 一个关于Zend O+的小分享 - 风雪之隅 在PHP中使用协程实现多任务调度 - 风雪之隅 Curl的毫秒超时的一个"Bug" - 风雪之隅 PHP8.0的Named Parameter - 风雪之隅 关于PHP,关于Realsee - 风雪之隅 PHP8新特性之match表达式 - 风雪之隅 PHP 8新特性之JIT简介 - 风雪之隅 使用SSE2指令高效实现strtolower - 风雪之隅 使用OSC52实现iTerm2远程pbcopy - 风雪之隅 Yaf 3.2 发布 - 风雪之隅 使用PHP Socket开发Yar TCP服务 - 风雪之隅 Yac 2.1 升级说明 - 风雪之隅 Yaf-3.1 10%性能提升版 - 风雪之隅 PHP FFI详解 - 一种全新的PHP扩展方式 - 风雪之隅 使用SSE2指令集加速字符替换 - 风雪之隅 Yaf_Loader重构测试 - 风雪之隅 PHP_INT_MIN 和 -9223372036854775808 - 风雪之隅 深入理解PHP7内核之FAST_ZPP - 风雪之隅 深入理解PHP7内核之HashTable - 风雪之隅 var_dump(1...9)输出什么? - 风雪之隅 使用内存硬盘(tmpfs)来加速你的网站 - 风雪之隅 print不是函数 - 风雪之隅 令人困惑的strtotime - 风雪之隅 深入理解PHP7内核之Reference - 风雪之隅 深入理解PHP7内核之zval - 风雪之隅 PHP的性能演进(从PHP5.0到PHP7.1的性能全评测) - 风雪之隅 让PHP7达到最高性能的几个Tips - 风雪之隅 写在PHP7发布之际的一些话 - 风雪之隅 让你的PHP7更快之Hugepage - 风雪之隅 让你的PHP7更快(GCC PGO) - 风雪之隅 Yaconf - 一个高性能的配置管理扩展 - 风雪之隅 记录一场没有胜利的局部战斗 - 风雪之隅 PHP7 VS HHVM (Wordpress) - 风雪之隅 GCC优化引起的一个"问题" - 风雪之隅 Weibo LAMP演变 - 6月在上海分享的PPT - 风雪之隅 一个小玩意PHP-Valgrind的介绍 - 风雪之隅 PHP浮点数的一个常见问题的解答 - 风雪之隅 Yac (Yet Another Cache) - 无锁共享内存Cache PDOStatement::bindParam的一个陷阱 - 风雪之隅 Mcrypt响应慢的一个原因 - 风雪之隅 一个程序员眼中的价值 - 风雪之隅 一个关于if else容易迷惑的问题 - 风雪之隅
Yaconf-1.1 40%速度提升版 - 风雪之隅
laruence · 2020-03-12 · via 风雪之隅

Yaconf是一个高性能的PHP配置容器, 它在PHP启动的时候把格式为INI的配置文件Parse后存储在PHP的常驻内存中,不需要每次请求的时候都来分析配置文件,并且在获取配置项的时候"zero-copy",具体的介绍可以看我2015年发布的时候写的介绍:Yaconf - 一个高性能的配置管理扩展

Yaconf在微博被大量使用,也稳定运行了这么多年,但是2015年发布后基本也没有什么大的变化。

最近因为疫情,我对Yaconf做了一系列的重构,主要是减少取过程中的内存使用,基本重写了整体的逻辑,那性能优化的结果如何呢? 我们来做个简单的测试。

首先测试配置文件如下:

name="yaconf"
version="1.1.0"

[author]
name="Laruence"
blog.address="https://www.laruence.com"

[developer : author]
projects.yaf.repo="https://github.com/laruence/yaf"

测试脚本如下:

<?php
function bench($key) {
	$count = 1000000;
	$start = microtime(true);
	while ($count--) {
		Yaconf::get($key);
	}
	printf("%s: %fs\n", $key, microtime(true) - $start);
}

bench("config.name");
bench("config.author.name");
bench("config.author.blog.address");
bench("config.developer.projects.yaf.repo");
?>

首先我们用yaconf-1.0.8来测试:

config.name: 0.129616s
config.author.name: 0.172129s
config.author.blog.address: 0.206659s
config.developer.projects.yaf.repo: 0.248205s

然后我们来用yaconf-1.1.0测试下:

config.name: 0.075837s
config.author.name: 0.098553s
config.author.blog.address: 0.144033s
config.developer.projects.yaf.repo: 0.144580s

可以看到获取配置平均能有40%的耗时减少,尤其当你使用链式方法获取配置内容的时候,越长提升越明显。

好了, Yaconf-1.1.0已经发布到PECL: Yaconf

enjoy!