]> git.mjollnir.org Git - moodle.git/commitdiff
moodlelib: moodle_request_shutdown() prints included files
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:46:39 +0000 (07:46 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:46:39 +0000 (07:46 +0000)
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

index d9e4ef3de47031377611200d6bec17c78dadc9c4..cb55b6e898b5d7dd2d851fb5d886fec726f9f2c0 100644 (file)
@@ -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)");
+            }
+        }
     }
 }