From 2a2057736ee07a0f1cf4f7f1092d9a4bb8fb9ecd Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:46:39 +0000 Subject: [PATCH] moodlelib: moodle_request_shutdown() prints included files If MDL_PERFINC is defined, we now print to errorlog a listing of the files included, their size, and then a total size. The total size isn't the most important metric, though it does give us a good idea of how much PHP the PHP engine is parsing for us. The main cost is still in the seeks involved. Even when using precompilers -- our best-case scenario -- each include or require forces at least 2 stat()s to compare timestamps in the php file vs the precompiled file. If the working set fits in buffers we are fine, but our 60+ stat() calls per page is quite a bit. --- lib/moodlelib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d9e4ef3de4..cb55b6e898 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6871,6 +6871,25 @@ function moodle_request_shutdown() { $perf = get_performance_info(); error_log("PERF: " . $perf['txt']); } + if (defined('MDL_PERFINC')) { + $inc = get_included_files(); + $ts = 0; + foreach($inc as $f) { + if (preg_match(':^/:', $f)) { + $fs = filesize($f); + $ts += $fs; + $hfs = display_size($fs); + error_log(substr($f,strlen($CFG->dirroot)) . " size: $fs ($hfs)" + , NULL, NULL, 0); + } else { + error_log($f , NULL, NULL, 0); + } + } + if ($ts > 0 ) { + $hts = display_size($ts); + error_log("Total size of files included: $ts ($hts)"); + } + } } } -- 2.39.5