Skip to content

Instantly share code, notes, and snippets.

View Majkl578's full-sized avatar
💥
breaking builds

Michael Moravec Majkl578

💥
breaking builds
View GitHub Profile
@Majkl578
Majkl578 / intro.md
Created August 21, 2012 08:50 — forked from juzna/intro.md
Nette\Object performance tests

Nette\Object performance tests

I guess you already saw a short note Latency Numbers Every Programmer Should Know. I wanted to check how well Nette performs with its magic properties on Nette\Object.

You can see the testing code below together with raw output on my machine.

It show how much time in seconds it took to execute one million iterations of a particular action, thus it is also time in microseconds of one such call. You should compare it to null test, which execute empty iterations.

Results

<?php
if (is_array($value) && (!isset($value['class']) || !is_scalar($value['class']))) {
throw new \InvalidArgumentException("Repository $name doesn't have defined 'class' parameter");
}
$className = is_array($value) ? $value['class'] : $value;
@Majkl578
Majkl578 / gist:1306559
Created October 22, 2011 22:23 — forked from Solution/gist:1306541
Price
<?php
function cutPrice($price)
{
return number_format($price, is_float($price) ? 2 : 0, '.', ' ');
}
var_dump(cutPrice(12185418));
var_dump(cutPrice(12185418.4841));
<?php
Nette\Debug::enable(array('12.34.56.78, 11.22.33.44'), NULL,'xxx@gmail.com');
$application->catchExceptions = Nette\Environment::isProduction();
<?php
namespace DataGrid\DataSources\Dibi;
use DataGrid\DataSources\IDataSource,
DataGrid\DataSources,
dibi;
/**
* Dibi fluent based data source
<?php
namespace App\Controls;
class Foo extends \App\Basis\Control
{
}