Skip to content

Commit

Permalink
added athletic benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 8, 2015
1 parent 500b08e commit 3f409fa
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -9,3 +9,6 @@ php:
before_script:
- composer install
sudo: false
script:
- phpunit
- vendor/bin/athletic --path test/Benchmark --formatter GroupedFormatter
4 changes: 4 additions & 0 deletions composer.json
Expand Up @@ -26,6 +26,10 @@
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"athletic/athletic": "~0.1"
},
"autoload": {
"psr-4": {
"Auryn\\": "lib/"
Expand Down
63 changes: 63 additions & 0 deletions test/Benchmark/ExecuteBenchmark.php
@@ -0,0 +1,63 @@
<?php

namespace Auryn\Test\Benchmark;

use Athletic\AthleticEvent;
use Auryn\Injector;

class ExecuteBenchmark extends AthleticEvent
{
private $injector;
private $noop;

public function classSetUp()
{
$this->injector = new Injector();
$this->noop = new Noop();
}

/**
* @baseline
* @iterations 10000
*/
public function native_invoke_closure()
{
call_user_func(function () {
// call-target, intenionally left empty
});
}

/**
* @iterations 10000
*/
public function native_invoke_method()
{
call_user_func(array($this->noop, 'noop'));
}

/**
* @iterations 10000
*/
public function invoke_closure()
{
$this->injector->execute(function () {
// call-target, intenionally left empty
});
}

/**
* @iterations 10000
*/
public function invoke_method()
{
$this->injector->execute(array($this->noop, 'noop'));
}

/**
* @iterations 10000
*/
public function invoke_with_named_parameters()
{
$this->injector->execute(array($this->noop, 'namedNoop'), array(':name' => 'foo'));
}
}
17 changes: 17 additions & 0 deletions test/Benchmark/Noop.php
@@ -0,0 +1,17 @@
<?php

namespace Auryn\Test\Benchmark;

class Noop {
public function noop() {
// call-target, intenionally left empty
}

public function namedNoop($name) {
// call-target, intenionally left empty
}

public function typehintedNoop(noop $noop) {
// call-target, intenionally left empty
}
}

0 comments on commit 3f409fa

Please sign in to comment.