Added phpbench for benchmarking

This commit is contained in:
vladar 2016-04-28 19:21:24 +06:00
parent 3dec7a9995
commit 71924f1154
3 changed files with 43 additions and 1 deletions

35
benchmarks/LexerBench.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace GraphQL\Benchmarks;
use GraphQL\Language\Lexer;
use GraphQL\Language\Source;
use GraphQL\Language\Token;
use GraphQL\Type\Introspection;
/**
* @BeforeMethods({"setUp"})
* @OutputTimeUnit("milliseconds", precision=3)
*/
class LexerBench
{
private $introQuery;
public function setUp()
{
$this->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);
}
}

View File

@ -24,7 +24,8 @@
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"GraphQL\\Tests\\": "tests/" "GraphQL\\Tests\\": "tests/",
"GraphQL\\Benchmarks\\": "benchmarks/"
} }
} }
} }

6
phpbench.json Normal file
View File

@ -0,0 +1,6 @@
{
"bootstrap": "vendor/autoload.php",
"path": "benchmarks",
"retry_threshold": 5,
"time_unit": "milliseconds"
}