Memory usage of a part of the script
Posted: Tue Jan 27, 2009 5:08 am
I am trying to do a small memory usage test on two different web applications. The problem is, that I haven't found any methods to calculate the mamximum memory usage for only a part of the script. The PHP function memory_get_peak_usage returns the peak usage of the whole script, and the peak usage is reached already at the beginning of the script.
Below is a short description about the scripts.
The included_file.php:
I am using Apache/2.2.8 (Win32) PHP/5.2.6 on Windows XP.
Is there any possibilities to get what I need?
Thanks!
Below is a short description about the scripts.
Code: Select all
<?php
// Some code, which shouldn't affect to the test
include_once('included_file.php');
// Some more code, which shouldn't affect to the test
?>Code: Select all
<?php
// Some more code, which shouldn't affect to the test
// *** The test starts here. ***
$initial_memory = memory_get_usage();
//
// Here comes the part of the script,
// which peak memory usage I want to test!
//
$end_memory = memory_get_usage();
$peak_memory = mystery_to_me( ';)' );
// *** The test ends here. ***
// Some more code...
?>Is there any possibilities to get what I need?
Thanks!