Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/revslide.../admin/includes
File: debug.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if( !defined( 'ABSPATH') ) exit();
[2] Fix | Delete
[3] Fix | Delete
class RevSliderMemoryUsageInformation
[4] Fix | Delete
{
[5] Fix | Delete
[6] Fix | Delete
private $real_usage;
[7] Fix | Delete
private $statistics = array();
[8] Fix | Delete
[9] Fix | Delete
// Memory Usage Information constructor
[10] Fix | Delete
public function __construct($real_usage = false)
[11] Fix | Delete
{
[12] Fix | Delete
$this->real_usage = $real_usage;
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
// Returns current memory usage with or without styling
[16] Fix | Delete
public function getCurrentMemoryUsage($with_style = true)
[17] Fix | Delete
{
[18] Fix | Delete
$mem = memory_get_usage($this->real_usage);
[19] Fix | Delete
return ($with_style) ? $this->byteFormat($mem) : $mem;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
// Returns peak of memory usage
[23] Fix | Delete
public function getPeakMemoryUsage($with_style = true)
[24] Fix | Delete
{
[25] Fix | Delete
$mem = memory_get_peak_usage($this->real_usage);
[26] Fix | Delete
return ($with_style) ? $this->byteFormat($mem) : $mem;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
// Set memory usage with info
[30] Fix | Delete
public function setMemoryUsage($info = '')
[31] Fix | Delete
{
[32] Fix | Delete
$this->statistics[] = array(
[33] Fix | Delete
'time' => time(), //microtime(),
[34] Fix | Delete
'info' => $info,
[35] Fix | Delete
'memory_usage' => $this->getCurrentMemoryUsage());
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
// Print all memory usage info and memory limit and
[39] Fix | Delete
public function printMemoryUsageInformation()
[40] Fix | Delete
{
[41] Fix | Delete
//return true;
[42] Fix | Delete
echo '<pre>';
[43] Fix | Delete
foreach ($this->statistics as $satistic)
[44] Fix | Delete
{
[45] Fix | Delete
echo "Time: " . $satistic['time'] .
[46] Fix | Delete
" | Memory Usage: " . $satistic['memory_usage'] .
[47] Fix | Delete
" | Info: " . $satistic['info'];
[48] Fix | Delete
echo "\n";
[49] Fix | Delete
}
[50] Fix | Delete
echo "\n\n";
[51] Fix | Delete
echo "Peak of memory usage: " . $this->getPeakMemoryUsage();
[52] Fix | Delete
echo "\n\n";
[53] Fix | Delete
echo '</pre>';
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
// Set start with default info or some custom info
[57] Fix | Delete
public function setStart($info = 'Initial Memory Usage')
[58] Fix | Delete
{
[59] Fix | Delete
$this->setMemoryUsage($info);
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
// Set end with default info or some custom info
[63] Fix | Delete
public function setEnd($info = 'Memory Usage at the End')
[64] Fix | Delete
{
[65] Fix | Delete
$this->setMemoryUsage($info);
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
// Byte formatting
[69] Fix | Delete
private function byteFormat($bytes, $unit = "", $decimals = 2)
[70] Fix | Delete
{
[71] Fix | Delete
$units = array('B' => 0, 'KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4,
[72] Fix | Delete
'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8);
[73] Fix | Delete
[74] Fix | Delete
$value = 0;
[75] Fix | Delete
if ($bytes > 0)
[76] Fix | Delete
{
[77] Fix | Delete
// Generate automatic prefix by bytes
[78] Fix | Delete
// If wrong prefix given
[79] Fix | Delete
if (!array_key_exists($unit, $units))
[80] Fix | Delete
{
[81] Fix | Delete
$pow = floor(log($bytes) / log(1024));
[82] Fix | Delete
$unit = array_search($pow, $units);
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Calculate byte value by prefix
[86] Fix | Delete
$value = ($bytes / pow(1024, floor($units[$unit])));
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
// If decimals is not numeric or decimals is less than 0
[90] Fix | Delete
// then set default value
[91] Fix | Delete
if (!is_numeric($decimals) || $decimals < 0)
[92] Fix | Delete
{
[93] Fix | Delete
$decimals = 2;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
// Format output
[97] Fix | Delete
return sprintf('%.' . $decimals . 'f ' . $unit, $value);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
}
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function