Skip to content

Commit

Permalink
More realiable benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Feb 26, 2017
1 parent 1ff36fc commit 48ebb1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions benchmarks/Base85Bench.php
Expand Up @@ -18,6 +18,10 @@

/**
* @BeforeMethods({"init"})
* @Iterations(5)
* @Warmup(2)
* @OutputTimeUnit("seconds")
* @OutputMode("throughput")
*/

class Base85Bench
Expand All @@ -32,7 +36,7 @@ public function init()
}

/**
* @Revs(10)
* @Revs(1000)
*/
public function benchGmpEncoder()
{
Expand All @@ -41,7 +45,7 @@ public function benchGmpEncoder()
}

/**
* @Revs(10)
* @Revs(1000)
*/
public function benchPhpEncoder()
{
Expand Down
1 change: 1 addition & 0 deletions src/Base85.php
Expand Up @@ -18,6 +18,7 @@
final class Base85 extends Base85\BaseEncoder
{
/* Adobe ASCII85. Only all zero data exception, ignore whitespace. */
/* https://www.adobe.com/products/postscript/pdfs/PLRM.pdf */
const ASCII85 = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu";

/* https://rfc.zeromq.org/spec:32/Z85/ */
Expand Down
8 changes: 4 additions & 4 deletions tests/Base85Test.php
Expand Up @@ -30,16 +30,16 @@ public function testShouldEncodeAndDecodeRandomBytes()
$data = random_bytes(128);
$encoded = (new PhpEncoder)->encode($data);
$encoded2 = (new GmpEncoder)->encode($data);
//$encoded3 = BcmathEncoder::encode($data);
$encoded3 = (new BcmathEncoder)->encode($data);
$decoded = (new PhpEncoder)->decode($encoded);
$decoded2 = (new GmpEncoder)->decode($encoded2);
//$decoded3 = BcmathEncoder::decode($encoded3);
$decoded3 = (new BcmathEncoder)->decode($encoded3);

$this->assertEquals($encoded, $encoded2);
//$this->assertEquals($encoded, $encoded3);
$this->assertEquals($encoded, $encoded3);

$this->assertEquals($decoded2, $decoded);
//$this->assertEquals($decoded3, $decoded);
$this->assertEquals($decoded3, $decoded);
$this->assertEquals($data, $decoded);
$this->assertEquals($data, $decoded2);
//$this->assertEquals($data, $decoded3);
Expand Down

0 comments on commit 48ebb1b

Please sign in to comment.