This repository has been archived by the owner on May 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from yuloh/phpbench
Add some benchmarks
- Loading branch information
Showing
10 changed files
with
1,736 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
/.scrutinizer.yml export-ignore | ||
/tests export-ignore | ||
/docs export-ignore | ||
phpbench.json export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
/** | ||
* @BeforeMethods({"setUp"}) | ||
* @AfterMethods({"tearDown"}) | ||
*/ | ||
abstract class Benchmark | ||
{ | ||
public function setUp() | ||
{ | ||
|
||
} | ||
|
||
public function tearDown() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
use League\JsonGuard\Dereferencer; | ||
|
||
/** | ||
* @Groups({"dereference"}) | ||
* @Revs(100) | ||
*/ | ||
abstract class DereferenceBenchmark extends Benchmark | ||
{ | ||
protected $schema; | ||
|
||
abstract public function getSchema(); | ||
|
||
public function setUp() | ||
{ | ||
$this->schema = $this->getSchema(); | ||
} | ||
|
||
public function benchJsonGuard() | ||
{ | ||
(new Dereferencer())->dereference($this->schema); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
class MetaSchemaDereferenceBench extends DereferenceBenchmark | ||
{ | ||
public function getSchema() | ||
{ | ||
return json_decode(file_get_contents(__DIR__ . '/../fixtures/draft4-schema.json')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
class MetaSchemaValidationBench extends ValidationBenchmark | ||
{ | ||
public function getData() | ||
{ | ||
return $this->getSchema(); | ||
} | ||
|
||
public function getSchema() | ||
{ | ||
return json_decode(file_get_contents(__DIR__ . '/../fixtures/draft4-schema.json')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
class SwaggerValidationBench extends ValidationBenchmark | ||
{ | ||
public function getData() | ||
{ | ||
return json_decode(file_get_contents(__DIR__ . '/../fixtures/swagger2.json')); | ||
} | ||
|
||
public function getSchema() | ||
{ | ||
return json_decode(file_get_contents(__DIR__ . '/../fixtures/draft4-schema.json')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace League\JsonGuard\Bench; | ||
|
||
use League\JsonGuard\Dereferencer; | ||
use League\JsonGuard\Validator; | ||
|
||
/** | ||
* @Groups({"validation"}) | ||
* @Revs(100) | ||
*/ | ||
abstract class ValidationBenchmark extends Benchmark | ||
{ | ||
protected $data; | ||
|
||
protected $schema; | ||
|
||
abstract public function getData(); | ||
|
||
abstract public function getSchema(); | ||
|
||
public function setUp() | ||
{ | ||
$this->data = $this->getData(); | ||
$this->schema = (new Dereferencer())->dereference($this->getSchema()); | ||
} | ||
|
||
public function benchJsonGuard() | ||
{ | ||
(new Validator($this->data, $this->schema))->errors(); | ||
} | ||
} |
Oops, something went wrong.