Microscopic Analysis of PHP Performance_PHP Tutorial
Jul 12, 2016 am 09:08 AMMicro-analysis of PHP performance
1. Functions and commands related to performance analysis$start= microtime(true); echo $start."\n"; $end = microtime(true); echo $end."\n"; echo ($end-$start)."\n";
$base_memory= memory_get_usage(); echo "Hello,world!\n"; $end_memory= memory_get_usage(); $peak_memory= memory_get_peak_usage(); echo $base_memory,"\t",$end_memory,"\t",($end_memory-$base_memory),"\t", $peak_memory,"\n";
$baseMemory= memory_get_usage(); class User { private $uid; function __construct($uid) { $this->uid= $uid; } } for($i=0;$i<100000;$i++) { $obj= new User($i); if ( $i% 10000 === 0 ) { echo sprintf( '%6d: ', $i), memory_get_usage(), " bytes\n"; } } echo " peak: ",memory_get_peak_usage(true), " bytes\n";
[root@localhostphpperf]# php52 memory.php 0: 93784 bytes 10000: 93784 bytes …… 80000: 93784 bytes 90000: 93784 bytes peak: 262144 bytes
[root@localhostphpperf]# phpmemory.php 0: 634992 bytes 10000: 634992 bytes …… 80000: 634992 bytes 90000: 634992 bytes peak: 786432 bytes
[root@localhostphpperf]# php56 memory.php 0: 224944 bytes 10000: 224920 bytes …… 80000: 224920 bytes 90000: 224920 bytes peak: 262144 bytes
[root@localhostphpperf]# php7 memory.php 0: 353912 bytes 10000: 353912 bytes …… 80000: 353912 bytes 90000: 353912 bytes peak: 2097152 bytes
$baseMemory= memory_get_usage(); class User { private $uid; function __construct($uid) { $this->uid= $uid; } } for($i=0;$i<100000;$i++) { $obj= new User($i); $obj->self = $obj; if ( $i% 5000 === 0 ) { echo sprintf( '%6d: ', $i), memory_get_usage(), " bytes\n"; } }

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The difference between vivox100s and x100: performance comparison and function analysis

How to show hidden performance overlays in Windows 11

Comparing the performance of Win11 and Win10 systems, which one is better?

Windows 10 vs. Windows 11 performance comparison: Which one is better?

Kirin 8000 processor competes with Snapdragon series: Who can be king?

Comparison of PHP and Go languages: big performance difference

Performance comparison of different Java frameworks

The local running performance of the Embedding service exceeds that of OpenAI Text-Embedding-Ada-002, which is so convenient!
