Skip to content

Commit 518067c

Browse files
committed
Initial
0 parents  commit 518067c

9 files changed

+119
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml
4+
composer.phar

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
sudo: false
4+
5+
cache:
6+
directories:
7+
- $HOME/.composer/cache
8+
9+
before_script:
10+
- composer install
11+
12+
script:
13+
- phpunit

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Daniel Leech
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PHP Parser Benchmarks
2+
==================
3+
4+
[![Build Status](https://travis-ci.org/phpbench/parser-benchmarks.svg?branch=master)](https://travis-ci.org/phpbench/parser-benchmarks)
5+
[![StyleCI](https://styleci.io/repos/<repo-id>/shield)](https://styleci.io/repos/<repo-id>)

composer.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "phpbench/parser-benchmarks",
3+
"description": "PHP Parser Benchmarks",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Daniel Leech",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"require": {
12+
"nikic/php-parser": "^4.0",
13+
"microsoft/tolerant-php-parser": "^0.0.10"
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "5.0",
17+
"phpbench/phpbench": "^0.14.0"
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"Phpbench\\Benchmarks\\Parser\\": "lib/"
22+
}
23+
},
24+
"extra": {
25+
"branch-alias": {
26+
"dev-master": "1.0-dev"
27+
}
28+
}
29+
}

lib/ParserBenchCase.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Phpbench\Benchmarks\Parser;
4+
5+
/**
6+
* @Revs(10)
7+
* @Iterations(33)
8+
*/
9+
abstract class ParserBenchCase
10+
{
11+
public function getSource(): string
12+
{
13+
return file_get_contents(__DIR__ . '/../vendor/phpunit/phpunit/src/Framework/TestCase.php');
14+
}
15+
16+
abstract public function benchParser();
17+
}

lib/PhpParserBench.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Phpbench\Benchmarks\Parser;
4+
5+
use PhpParser\ParserFactory;
6+
7+
class PhpParserBench extends ParserBenchCase
8+
{
9+
public function benchParser()
10+
{
11+
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
12+
$parser->parse($this->getSource());
13+
}
14+
}

lib/TolerantParserBench.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Phpbench\Benchmarks\Parser;
4+
5+
use Microsoft\PhpParser\Parser;
6+
use PhpParser\ParserFactory;
7+
8+
class TolerantParserBench extends ParserBenchCase
9+
{
10+
public function benchParser()
11+
{
12+
$parser = new Parser();
13+
$parser->parseSourceFile($this->getSource());
14+
}
15+
}

phpbench.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"bootstrap": "vendor/autoload.php"
3+
}

0 commit comments

Comments
 (0)