예제 #1
0
 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
0
 /**
  * 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
0
 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
0
파일: Timer.php 프로젝트: Doluci/tomatocart
 public function getMemoryLeak()
 {
     return "Memory delta: " . Piwik::getPrettySizeFromBytes($this->getMemoryUsage() - $this->memoryStart);
 }
예제 #5
0
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()));
    }
}