From 71924f115448039db8f0813be2f5a730089d4bed Mon Sep 17 00:00:00 2001 From: vladar Date: Thu, 28 Apr 2016 19:21:24 +0600 Subject: [PATCH] Added phpbench for benchmarking --- benchmarks/LexerBench.php | 35 +++++++++++++++++++++++++++++++++++ composer.json | 3 ++- phpbench.json | 6 ++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 benchmarks/LexerBench.php create mode 100644 phpbench.json diff --git a/benchmarks/LexerBench.php b/benchmarks/LexerBench.php new file mode 100644 index 0000000..5f83cd8 --- /dev/null +++ b/benchmarks/LexerBench.php @@ -0,0 +1,35 @@ +introQuery = new Source(Introspection::getIntrospectionQuery()); + } + + /** + * @Warmup(2) + * @Revs(100) + * @Iterations(5) + */ + public function benchIntrospectionQuery() + { + $lexer = new Lexer($this->introQuery); + + do { + $token = $lexer->nextToken(); + } while ($token->kind !== Token::EOF); + } +} diff --git a/composer.json b/composer.json index dabf1cd..724a512 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ }, "autoload-dev": { "psr-4": { - "GraphQL\\Tests\\": "tests/" + "GraphQL\\Tests\\": "tests/", + "GraphQL\\Benchmarks\\": "benchmarks/" } } } diff --git a/phpbench.json b/phpbench.json new file mode 100644 index 0000000..774a177 --- /dev/null +++ b/phpbench.json @@ -0,0 +1,6 @@ +{ + "bootstrap": "vendor/autoload.php", + "path": "benchmarks", + "retry_threshold": 5, + "time_unit": "milliseconds" +}