Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------
- MAIN FILE (test_include.php)
- --------------------------------------
- <?php
- $loop_time = 3;
- include('include_file1.php');
- include('include_file2.php');
- include('include_file3.php');
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file1.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(large_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file1.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(large_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- echo PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file2.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(small_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file2.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(small_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- echo PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file3.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(empty_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file3.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(empty_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- /* REVERSE */
- echo PHP_EOL,'reversing order and retesting ...',PHP_EOL,PHP_EOL;
- /***********/
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file3.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(empty_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file3.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(empty_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- echo PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file2.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(small_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file2.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(small_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- echo PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include_once('include_file1.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include_once(large_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- $iterations = 0;
- $start_time = microtime(true);
- $duration = 0;
- while ($duration <= $loop_time) {
- include('include_file1.php');
- $iterations++;
- $duration = microtime(true) - $start_time;
- }
- echo 'include(large_file): ',$iterations,' iterations in ',$duration,' seconds',PHP_EOL;
- ?>
- ---------------------------------
- LARGE INCLUDE (include_file1.php)
- ---------------------------------
- <?php
- if (defined('INCLUDE_FILE2')) return;
- define('INCLUDE_FILE2',true);
- sleep ($loop_time);
- /* COPY / PASTE / REPEAT the following line about 1250 times to increase file size */
- /* Use up a bunch of memory or disk space to make the include more "costly" */
- /* Use up a bunch of memory or disk space to make the include more "costly" */
- /* ... /*
- ?>
- ---------------------------------
- SMALL INCLUDE (include_file2.php)
- ---------------------------------
- <?php
- if (defined('INCLUDE_FILE2')) return;
- define('INCLUDE_FILE2',true);
- sleep ($loop_time);
- ?>
- ----------------------------------
- EMPTY INCLUDE (include_file3.php)
- ----------------------------------
- ----------------------------------
- TEST RESULTS
- ----------------------------------
- D:\www\manual>php test_include.php
- include(large_file): 12118 iterations in 3.015625 seconds
- include_once(large_file): 196366 iterations in 3.015625 seconds
- include(small_file): 34986 iterations in 3.015625 seconds
- include_once(small_file): 222284 iterations in 3.015625 seconds
- include(empty_file): 68155 iterations in 3.015625 seconds
- include_once(empty_file): 220433 iterations in 3.015625 seconds
- reversing order and retesting ...
- include_once(empty_file): 192640 iterations in 3.015625 seconds
- include(empty_file): 68381 iterations in 3.015625 seconds
- include_once(small_file): 222204 iterations in 3.015625 seconds
- include(small_file): 34714 iterations in 3.015625 seconds
- include_once(large_file): 226388 iterations in 3.015625 seconds
- include(large_file): 9577 iterations in 3.015625 seconds
- D:\www\manual>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement