getMemoryPeak() public method

Returns the memory peak, readable or not
public getMemoryPeak ( $raw = false, string $format = null ) : string | float
$format string The format to display (printf format)
return string | float
Ejemplo n.º 1
0
 public function testGetMemoryPeak()
 {
     $bench = new Ubench();
     $this->assertRegExp('/^[0-9.]+Mb/', $bench->getMemoryPeak());
     $this->assertInternalType('integer', $bench->getMemoryPeak(true));
     $this->assertRegExp('/^[0-9]+Mb/', $bench->getMemoryPeak(false, '%d%s'));
 }
Ejemplo n.º 2
0
 public function testCallableWithArguments()
 {
     $bench = new Ubench();
     $result = $bench->run(function ($one, $two) {
         return $one + $two;
     }, 1, 2);
     $this->assertEquals(3, $result);
     $this->assertNotNull($bench->getTime());
     $this->assertNotNull($bench->getMemoryUsage());
     $this->assertNotNull($bench->getMemoryPeak());
 }
Ejemplo n.º 3
0
<?php

/**
 * This file is part of Cartesian Product.
 *
 * (c) Marco Garofalo <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Nerd\CartesianProduct\CartesianProduct;
require __DIR__ . '/../vendor/autoload.php';
$bench = new Ubench();
$cartesianProduct = new CartesianProduct();
$cartesianProduct->appendSet(array('a', 'b', 'c'))->appendSet(array('d', 'e'))->appendSet(array('f', 'g', 'h'))->appendSet(array('i', 'j'))->appendSet(array('k', 'l'))->appendSet(array('m', 'n'))->appendSet(array('o'))->appendSet(array('p'))->appendSet(array('q', 'r', 's', 't'))->appendSet(array('u', 'v', 'w'))->appendSet(array('x', 'y'))->appendSet(array('z'));
$bench->start();
foreach ($cartesianProduct as $index => $product) {
    printf("[%s] (%s)\n", $index, implode(',', $product));
}
$bench->end();
printf("Time elapsed: %s\n", $bench->getTime());
printf("Memory footprint: %s\n", $bench->getMemoryPeak());
Ejemplo n.º 4
0
    });
    $app->any('/def/{id}/{name}', ["admin", "middleware"], function () {
    });
    $app->any('/defg/{id}/{what}', function () {
    }, ["admin", "middleware"]);
    $app->any('/def/def/{shit}', ["admin", "action"], ['admin', 'middleware']);
    $app->any('/def/3/{zzz}', ["admin", "middleware"], ['admin', 'action'], function () {
    });
    try {
        $app->dispatch($getMock);
    } catch (RuntimeException $e) {
    }
}
/****************************************************************/
$bench->end();
// Get elapsed time and memory
echo $bench->getTime() . "\n";
// 156ms or 1.123s
echo $bench->getTime(true) . "\n";
// elapsed microtime in float
echo $bench->getTime(false, '%d%s') . "\n";
// 156ms or 1s
echo $bench->getMemoryPeak() . "\n";
// 152B or 90.00Kb or 15.23Mb
echo $bench->getMemoryPeak(true) . "\n";
// memory peak in bytes
echo $bench->getMemoryPeak(false, '%.3f%s') . "\n";
// 152B or 90.152Kb or 15.234Mb
// Returns the memory usage at the end mark
echo $bench->getMemoryUsage() . "\n";
// 152B or 90.00Kb or 15.23Mb
 /**
  * Imports stations information from EDDB
  */
 public function actionStations()
 {
     $eddbApi = Yii::$app->params['eddb']['archive'] . 'stations.json';
     $time = date('d-m-y_h');
     $file = Yii::getAlias('@app') . '/runtime/stations' . $time . '.json';
     // Download the data from EDDB if the data that we have is out of date
     if (!file_exists($file)) {
         $this->stdOut('Systems data from EDDB is out of date, fetching RAW JSON from EDDB');
         $curl = new Curl();
         $curl = new Curl();
         $curl->setOpt(CURLOPT_ENCODING, 'gzip');
         $curl->download($eddbApi, $file);
     }
     $bench = new \Ubench();
     $result = $bench->run(function ($file, $type) {
         $this->importJsonData($file, $type);
     }, $file, 'stations');
     $this->stdOut("Systems import completed\n");
     $this->stdOut($bench->getTime(false, '%d%s') . "\n");
     $this->stdOut($bench->getMemoryPeak(false, '%.3f%s') . "\n");
     $this->stdOut($bench->getMemoryUsage() . "\n");
 }
Ejemplo n.º 6
0
</head>
<body>

<?php 
require 'vendor/autoload.php';
require 'functions.php';
$bench = new Ubench();
$bench->start();
$faker = Faker\Factory::create();
//fake quots output
fakequote();
echo '<br>';
echo '<br>';
//fake nicknames output
echo ReleaseName\Release::random();
//fake names output
echo " " . $faker->name;
echo '<br>';
echo '<br>';
$bench->end();
echo "Benchmarked:";
echo '<br>';
echo $bench->getTime();
echo '<br>';
echo $bench->getMemoryPeak();
?>

</body>
</html>