2016-04-28 16:21:24 +03:00
|
|
|
<?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 {
|
2017-02-24 22:27:53 +03:00
|
|
|
$token = $lexer->advance();
|
2016-04-28 16:21:24 +03:00
|
|
|
} while ($token->kind !== Token::EOF);
|
|
|
|
}
|
|
|
|
}
|