Example #1
0
 /**
  * formats a filesize (binary prefix)
  * 
  * For more informations: <http://en.wikipedia.org/wiki/Binary_prefix>
  *
  * @param 	integer 	$byte
  * @param 	integer		$precision
  * @return 	string 		filesize
  */
 public static function formatFilesizeBinary($byte, $precision = 2)
 {
     $symbol = 'Byte';
     if ($byte >= 1024) {
         $byte /= 1024;
         $symbol = 'KiB';
     }
     if ($byte >= 1024) {
         $byte /= 1024;
         $symbol = 'MiB';
     }
     if ($byte >= 1024) {
         $byte /= 1024;
         $symbol = 'GiB';
     }
     if ($byte >= 1024) {
         $byte /= 1024;
         $symbol = 'TiB';
     }
     return StringUtil::formatNumeric(round($byte, $precision)) . ' ' . $symbol;
 }
 /**
  * @see	\wcf\action\AJAXInvokeAction::sendResponse()
  */
 protected function sendResponse()
 {
     // add benchmark and debug data
     if (ENABLE_BENCHMARK) {
         $this->response['benchmark'] = array('executionTime' => WCF::getBenchmark()->getExecutionTime() . 's', 'memoryUsage' => WCF::getBenchmark()->getMemoryUsage(), 'phpExecution' => StringUtil::formatNumeric((WCF::getBenchmark()->getExecutionTime() - WCF::getBenchmark()->getQueryExecutionTime()) / WCF::getBenchmark()->getExecutionTime() * 100) . '%', 'sqlExecution' => StringUtil::formatNumeric(WCF::getBenchmark()->getQueryExecutionTime() / WCF::getBenchmark()->getExecutionTime() * 100) . '%', 'sqlQueries' => WCF::getBenchmark()->getQueryCount());
         if (ENABLE_DEBUG_MODE) {
             $this->response['benchmark']['items'] = WCF::getBenchmark()->getItems();
         }
     }
     parent::sendResponse();
 }