mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-24 05:46:05 +03:00
Added phpbench for benchmarking
This commit is contained in:
parent
3dec7a9995
commit
71924f1154
35
benchmarks/LexerBench.php
Normal file
35
benchmarks/LexerBench.php
Normal 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);
|
||||
}
|
||||
}
|
@ -24,7 +24,8 @@
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"GraphQL\\Tests\\": "tests/"
|
||||
"GraphQL\\Tests\\": "tests/",
|
||||
"GraphQL\\Benchmarks\\": "benchmarks/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
phpbench.json
Normal file
6
phpbench.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"bootstrap": "vendor/autoload.php",
|
||||
"path": "benchmarks",
|
||||
"retry_threshold": 5,
|
||||
"time_unit": "milliseconds"
|
||||
}
|
Loading…
Reference in New Issue
Block a user