1. <?php
    2. $stratTime = microtime(true);
    3. $startMemory = memory_get_usage();
    4. $a = 1;
    5. for($i = 1; $i <= 100000; $i++){
    6. $a++;
    7. }
    8. echo $a;
    9. $endTime = microtime(true);
    10. $runtime = ($endTime - $stratTime) * 1000; //将时间转换为毫秒
    11. $endMemory = memory_get_usage();
    12. $usedMemory = ($endMemory - $startMemory) / 1024;
    13. echo "运行时间: {$runtime} 毫秒<br />";
    14. echo "耗费内存: {$usedMemory} K";