Skip to content

Instantly share code, notes, and snippets.

@dantleech
Last active September 17, 2016 14:17
Show Gist options
  • Select an option

  • Save dantleech/09547d9ecd145bb84c1b2e23e36a139c to your computer and use it in GitHub Desktop.

Select an option

Save dantleech/09547d9ecd145bb84c1b2e23e36a139c to your computer and use it in GitHub Desktop.
$ phpbench run UriBench.php --iterations=50 --revs=10000 --report=aggregate refactoring ✭ ✱ ◼
suite: 133a19512a7cb6e86f4c13f58dbe63264deda315, date: 2016-09-17, stime: 15:12:55
+-----------+-----------------------+--------+--------+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+---------+
| benchmark | subject | groups | params | revs | its | mem_peak | best | mean | mode | worst | stdev | rstdev | diff |
+-----------+-----------------------+--------+--------+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+---------+
| UriBench | benchString | | [] | 1000 | 50 | 712,312b | 0.887μs | 1.005μs | 0.995μs | 1.208μs | 0.067μs | 6.62% | 0.00% |
| UriBench | benchUriFromComponent | | [] | 1000 | 50 | 1,140,896b | 173.570μs | 184.079μs | 179.016μs | 231.550μs | 12.220μs | 6.64% | +99.45% |
| UriBench | benchUriFromString | | [] | 1000 | 50 | 1,163,416b | 226.812μs | 242.249μs | 235.223μs | 302.217μs | 16.728μs | 6.91% | +99.59% |
+-----------+-----------------------+--------+--------+------+-----+------------+-----------+-----------+-----------+-----------+----------+--------+---------+
<?php
use League\Uri\Schemes\Http;
class UriBench
{
/**
* Baseline - pretend we are creating a lazy Uri value object.
*/
public function benchString()
{
$uri = new \stdClass();
$uri->uri = 'https://www.example.com/edit/123';
}
public function benchUriFromComponent()
{
$uri = Http::createFromComponents(parse_url('https://www.example.com/edit/123'));
}
public function benchUriFromString()
{
$uri = Http::createFromString('https://www.example.com/edit/123');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment