- 开发无止境 -
Data: 2022-07-23 09:56:48Form: JournalClick: 10
PHP8 新特性:JITPHP 运行速度测试php文件<?php
// 返回当前时间戳的微秒数
$start = microtime(true) ;
$total = 0;
for ($i=0; $i < 1000000; $i++) {
$total += $i;
}
echo "Count: ".$i.",Total: " . $total . "\n";
// 返回当前时间戳的微秒数
$end = microtime(true);
// 计算开始到结束,所用时间
$spend = floor(($end - $start) * 1000);
echo "Time use: " . $spend . " ms\n";
?>
php7 测试
php8 测试
JIT (即时编译)编译器JIT (Just-In-Time)即时编译器是 PHP 8.0 中最重要的新功能之一,可以极大地提高性能。JIT 编译器将作为扩展集成到 php 中 Opcache 扩展 用于运行时将某些操作码直接转换为从 cpu 指令。 仅在启用 opcache 的情况下,JIT 才有效Opcache 扩展OPcache 通过将 PHP 脚本预编译的字节码存储到共享内存中来提升 PHP 的性能, 存储预编译字节码的好处就是:省去了每次加载和解析 PHP 脚本的开销。Opcache 开启zend_extension=opcache
Opcache 配置; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=0
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=10000
JIT 配置(新增)opcache.jit=tracing
opcache.jit_buffer_size=100M
JIT 速度测试
extension_dir = "ext"