LoginSignup
41
42

More than 5 years have passed since last update.

PHPの簡単ベンチマーク

Last updated at Posted at 2014-02-04

使用メモリや実行時間、読み込みファイル等の情報をスクリプト終了時に表示します。

$time = microtime(true);
register_shutdown_function(
    function() use ($time) {
        printf("Memory: %s / %s bytes\nTime: %f ms\nDeclared: %d classes\nIncluded: %d files > include_files.txt\n",
            number_format(memory_get_usage()),
            number_format(memory_get_peak_usage()),
            (microtime(true) - $time) * 1000,
            count(get_declared_classes()),
            count(get_included_files())
        );
        file_put_contents(__DIR__ . '/include_files.txt', print_r(get_included_files(), true));

    }
);
41
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
42