Skip to content

Commit

Permalink
Add PHPBench benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed May 7, 2016
1 parent 8f838bd commit 0e7c97a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions benchmarks/Base62Bench.php
@@ -0,0 +1,46 @@
<?php

use Tuupola\Base62\PhpEncoder;
use Tuupola\Base62\BcmathEncoder;
use Tuupola\Base62\GmpEncoder;

/**
* @BeforeMethods({"init"})
*/

class Base62Bench
{
private $data;

public function init()
{
$this->data = random_bytes(128);
}

/**
* @Revs(10)
*/
public function benchGmpEncoder()
{
$encoded = GmpEncoder::encode($this->data);
$decoded = GmpEncoder::decode($encoded);
}

/**
* @Revs(10)
*/
public function benchPhpEncoder()
{
$encoded = PhpEncoder::encode($this->data);
$decoded = PhpEncoder::decode($encoded);
}

/**
* @Revs(10)
*/
public function benchBcmathEncoder()
{
$encoded = BcmathEncoder::encode($this->data);
$decoded = BcmathEncoder::decode($encoded);
}
}
10 changes: 10 additions & 0 deletions phpbench.json
@@ -0,0 +1,10 @@
{
"bootstrap": "vendor/autoload.php",
"reports": {
"default": {
"generator": "table",
"cols": [ "subject", "mean", "diff" ],
"break": ["benchmark"]
}
}
}

0 comments on commit 0e7c97a

Please sign in to comment.