diff --git a/.travis.yml b/.travis.yml index 8051593..620f4c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,6 @@ php: before_script: - composer install sudo: false +script: + - phpunit + - vendor/bin/athletic --path test/Benchmark --formatter GroupedFormatter \ No newline at end of file diff --git a/composer.json b/composer.json index 72bb82b..700dc71 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,10 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "~4.5", + "athletic/athletic": "~0.1" + }, "autoload": { "psr-4": { "Auryn\\": "lib/" diff --git a/test/Benchmark/ExecuteBenchmark.php b/test/Benchmark/ExecuteBenchmark.php new file mode 100644 index 0000000..85f74ed --- /dev/null +++ b/test/Benchmark/ExecuteBenchmark.php @@ -0,0 +1,63 @@ +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')); + } +} diff --git a/test/Benchmark/Noop.php b/test/Benchmark/Noop.php new file mode 100644 index 0000000..378de89 --- /dev/null +++ b/test/Benchmark/Noop.php @@ -0,0 +1,17 @@ +