本文整理汇总了PHP中Piwik::getPrettySizeFromBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getPrettySizeFromBytes方法的具体用法?PHP Piwik::getPrettySizeFromBytes怎么用?PHP Piwik::getPrettySizeFromBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::getPrettySizeFromBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllTablesStatus
public static function getAllTablesStatus()
{
Piwik::checkUserIsSuperUser();
$db = Zend_Registry::get('db');
// http://dev.mysql.com/doc/refman/5.1/en/show-table-status.html
$tablesPiwik = Piwik::getTablesInstalled();
$total = array('Name' => 'Total', 'Data_length' => 0, 'Index_length' => 0, 'Rows' => 0);
$table = array();
foreach ($tablesPiwik as $tableName) {
$t = self::getTableStatus($tableName);
$total['Data_length'] += $t['Data_length'];
$total['Index_length'] += $t['Index_length'];
$total['Rows'] += $t['Rows'];
$t['Total_length'] = Piwik::getPrettySizeFromBytes($t['Index_length'] + $t['Data_length']);
$t['Data_length'] = Piwik::getPrettySizeFromBytes($t['Data_length']);
$t['Index_length'] = Piwik::getPrettySizeFromBytes($t['Index_length']);
$t['Rows'] = Piwik::getPrettySizeFromBytes($t['Rows']);
$table[] = $t;
}
$total['Total_length'] = Piwik::getPrettySizeFromBytes($total['Data_length'] + $total['Index_length']);
$total['Data_length'] = Piwik::getPrettySizeFromBytes($total['Data_length']);
$total['Index_length'] = Piwik::getPrettySizeFromBytes($total['Index_length']);
$total['TotalRows'] = Piwik::getPrettySizeFromBytes($total['Rows']);
$table['Total'] = $total;
return $table;
}
示例2: index
/**
* Returns the index for this plugin. Shows every other report defined by this plugin,
* except the '...ByYear' reports. These can be loaded as related reports.
*
* Also, the 'getIndividual...Summary' reports are loaded by AJAX, as they can take
* a significant amount of time to load on setups w/ lots of websites.
*/
public function index()
{
Piwik::checkUserIsSuperUser();
$view = Piwik_View::factory('index');
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
$view->databaseUsageSummary = $this->getDatabaseUsageSummary(true);
$view->trackerDataSummary = $this->getTrackerDataSummary(true);
$view->metricDataSummary = $this->getMetricDataSummary(true);
$view->reportDataSummary = $this->getReportDataSummary(true);
$view->adminDataSummary = $this->getAdminDataSummary(true);
list($siteCount, $userCount, $totalSpaceUsed) = Piwik_DBStats_API::getInstance()->getGeneralInformation();
$view->siteCount = Piwik::getPrettyNumber($siteCount);
$view->userCount = Piwik::getPrettyNumber($userCount);
$view->totalSpaceUsed = Piwik::getPrettySizeFromBytes($totalSpaceUsed);
echo $view->render();
}
示例3: oneShotTest_memoryUsageArrayIncreasingIndexOrJumps
function oneShotTest_memoryUsageArrayIncreasingIndexOrJumps()
{
ini_set('memory_limit', '200M');
Piwik::createConfigObject();
Piwik::createLogObject();
//test array[0] array[1] array[2]
//VS
// test array[0] array[100] array[200]
// same memory usage? hash
echo "start " . __FUNCTION__ . "<br>";
Piwik::printMemoryUsage();
$timer = new Piwik_Timer();
$testId = 2;
if ($testId == 1) {
echo "start incrementing index<br>";
$array = array();
for ($i = 0; $i < 1000000; $i++) {
$array[$i] = 1;
}
} elseif ($testId == 2) {
echo "start indexing by strings<br>";
$array = array();
for ($i = 0; $i < 1000000; $i++) {
$array[$i . "_" . $i] = 1;
}
} elseif ($testId == 3) {
echo "start jumping index<br>";
for ($i = 0; $i < 1000000; $i++) {
$array[$i * 100] = 1;
}
}
echo $timer . "<br>";
echo "size serialized:" . Piwik::getPrettySizeFromBytes(strlen(serialize($array))) . "<br>";
Piwik::printMemoryUsage();
echo "end " . __FUNCTION__ . "<br>";
}
示例4: getMemoryLeak
public function getMemoryLeak()
{
return "Memory delta: " . Piwik::getPrettySizeFromBytes($this->getMemoryUsage() - $this->memoryStart);
}
示例5: run_test
function run_test($klass, $method)
{
try {
// create instance
$reflector = new ReflectionClass($klass);
$instance = $reflector->newInstanceArgs();
// run setUp
$instance->setUp();
// start timing
$start_time = microtime(true);
$start_memory = memory_get_usage();
// run test
$result = $reflector->getMethod($method)->invoke($instance);
// end timing
$end_time = microtime(true);
$end_memory = memory_get_usage();
// run tearDown
$instance->tearDown();
// return results
echo json_encode(array('start_time' => round($start_time, 4), 'end_time' => round($end_time, 4), 'elapsed' => round($end_time - $start_time, 4), 'memory' => Piwik::getPrettySizeFromBytes($end_memory - $start_memory, $unit = null, $precision = 2), 'result' => $result));
} catch (Exception $ex) {
echo json_encode(array('error' => $ex->getMessage(), 'trace' => $ex->getTraceAsString()));
}
}