humanReadableFilesize() public static method

Generate a human readable size informations from provided Byte/s size
public static humanReadableFilesize ( integer $size ) : string
$size integer The size to convert in Byte
return string The readable size definition
コード例 #1
0
 public function actionIndex()
 {
     try {
         // sart time measuremnt
         $start = microtime(true);
         if ($this->verbose) {
             $this->output('[==================== VERBOSE ====================]');
         }
         $container = new CrawlContainer(['baseUrl' => $this->module->baseUrl, 'filterRegex' => $this->module->filterRegex, 'verbose' => $this->verbose, 'doNotFollowExtensions' => $this->module->doNotFollowExtensions, 'useH1' => $this->module->useH1]);
         if ($this->verbose) {
             $this->output('[================== VERBOSE END ==================]');
         }
         $timeElapsed = round((microtime(true) - $start) / 60, 2);
         $this->outputInfo('CRAWLER REPORT:');
         foreach ($container->getReport() as $type => $items) {
             if (count($items) > 0) {
                 $this->outputInfo(PHP_EOL . ' ' . $type . ':');
                 foreach ($items as $message) {
                     $this->output(' - ' . $message);
                 }
             }
         }
         $this->outputInfo(PHP_EOL . 'memory usage: ' . FileHelper::humanReadableFilesize(memory_get_usage()));
         $this->outputInfo('memory peak usage: ' . FileHelper::humanReadableFilesize(memory_get_peak_usage()));
         return $this->outputSuccess(PHP_EOL . 'Crawler finished in ' . $timeElapsed . ' min.');
     } catch (\Exception $e) {
         return $this->outputError('Exception in file "' . $e->getFile() . '" on line #' . $e->getLine() . ': ' . $e->getMessage());
     }
 }
コード例 #2
0
ファイル: FileHelperTest.php プロジェクト: luyadev/luya
 public function testHumandReadableFileSize()
 {
     $this->assertSame('1 B', FileHelper::humanReadableFilesize(1));
     $this->assertSame('10 B', FileHelper::humanReadableFilesize(10));
     $this->assertSame('100 B', FileHelper::humanReadableFilesize(100));
     $this->assertSame('1000 B', FileHelper::humanReadableFilesize(1000));
     $this->assertSame('9.77 KB', FileHelper::humanReadableFilesize(10000));
     $this->assertSame('97.66 KB', FileHelper::humanReadableFilesize(100000));
     $this->assertSame('976.56 KB', FileHelper::humanReadableFilesize(1000000));
     $this->assertSame('9.54 MB', FileHelper::humanReadableFilesize(10000000));
     $this->assertSame('95.37 MB', FileHelper::humanReadableFilesize(100000000));
     $this->assertSame('953.67 MB', FileHelper::humanReadableFilesize(1000000000));
     $this->assertSame('931.32 GB', FileHelper::humanReadableFilesize(1000000000000));
     $this->assertSame('90.95 TB', FileHelper::humanReadableFilesize(100000000000000));
     $this->assertSame('88.82 PB', FileHelper::humanReadableFilesize(100000000000000000));
     $this->assertSame('1 MB', FileHelper::humanReadableFilesize(1048577));
 }
コード例 #3
0
ファイル: Item.php プロジェクト: dojoVader/luya
 public function getSizeReadable()
 {
     return FileHelper::humanReadableFilesize($this->getSize());
 }