Skip to content

Refactoring to latest phpbench #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ composer require "phpcr/phpcr-benchmarks"
Run:

````bash
$ ./vendor/bin/phpbench run --config=vendor/phpcr/phpcr-benchmarks/config/phpbench
$ ./vendor/bin/phpbench run --config=vendor/phpcr/phpcr-benchmarks/config/phpbench.json
````

For more information see the documentation for [PHPBench](https://github.com/phpbench/phpbench).
4 changes: 2 additions & 2 deletions benchmarks/BaseBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace PHPCR\Benchmark;

use PHPCR\NodeInterface;
use PhpBench\Benchmark;
use PhpBench\BenchmarkInterface;
use PHPCR\ImportUUIDBehaviorInterface;

abstract class BaseBench implements Benchmark
abstract class BaseBench implements BenchmarkInterface
{
const ROOT_NAME = 'bench';
const ROOT_PATH = '/bench';
Expand Down
14 changes: 8 additions & 6 deletions benchmarks/InsertBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@

/**
* @group insert
* @processIsolation iteration
* @iterations 4
* @revs 4
*/
class InsertBench extends BaseBench
{
private $index = 1;

/**
* @description Insert nodes
* @paramProvider provideNbNodes
* @beforeMethod beforeResetWorkspace
* @iterations 2
*/
public function benchInsertNodes(Iteration $iteration)
public function benchInsertNodes($params)
{
$this->createNodes($this->getRootNode(), $iteration->getParameter('nb_nodes'), array(
$this->createNodes($this->getRootNode(), $params['nb_nodes'], array(
'string' => 'Hello',
'number' => 10,
'hello' => 'goodbye',
'goodbye' => 'hello',
), 0);
), $this->index * $params['nb_nodes']);
$this->index++;

$this->getSession()->save();
}
Expand Down
21 changes: 8 additions & 13 deletions benchmarks/QueryBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/**
* @group query
* @processIsolation iteration
*/
class QueryBench extends BaseBench
{
Expand All @@ -17,26 +16,24 @@ public function setUp()
}

/**
* @description No iterations
* @paramProvider provideQueries
* @iterations 5
* @group query_single_prop
*/
public function benchQuery(Iteration $iteration)
public function benchQuery($params)
{
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
$query->execute();
}

/**
* @description Retrive nodes for each row
* @paramProvider provideQueries
* @iterations 5
* @group query_single_prop
*/
public function benchQueryWithNodes(Iteration $iteration)
public function benchQueryWithNodes($params)
{
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
$results = $query->execute();

foreach ($results as $result) {
Expand All @@ -45,14 +42,13 @@ public function benchQueryWithNodes(Iteration $iteration)
}

/**
* @description Iterate over rows and retrieve properties
* @paramProvider provideQueries
* @iterations 5
* @group query_single_prop
*/
public function benchQueryIterate(Iteration $iteration)
public function benchQueryIterate($params)
{
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
$results = $query->execute();

foreach ($results as $result) {
Expand All @@ -61,14 +57,13 @@ public function benchQueryIterate(Iteration $iteration)
}

/**
* @description Run a select query with variable amount of properties
* @paramProvider provideProperties
* @iterations 5
* @group query_variable_props
*/
public function benchQueryIterateVariableProperties(Iteration $iteration)
public function benchQueryIterateVariableProperties($params)
{
$props = $iteration->getParameter('props');
$props = $params['props'];
$query = $this->getQueryManager()->createQuery(sprintf(
'SELECT %s FROM [nt:unstructured] WHERE valves IS NOT NULL'
, implode(', ', $props)), 'JCR-SQL2');
Expand Down
13 changes: 2 additions & 11 deletions benchmarks/TraversalBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use PHPCR\NodeInterface;

/**
* @processIsolation iteration
* @group traversal_full
* @iterations 6
*/
class TraversalBench extends BaseBench
{
Expand All @@ -14,21 +15,11 @@ public function setUp()
$this->loadDump('large_website.xml');
}

/**
* @description Full traversal
* @group traversal_full
* @iterations 3
*/
public function benchFullTraversal()
{
$this->traverse($this->getSession()->getRootNode());
}

/**
* @description Full traversal and read all properties
* @group traversal_full
* @iterations 3
*/
public function benchFullTraversalReadProperties()
{
$this->traverse($this->getSession()->getRootNode(), true);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"minimum-stability": "dev",
"require": {
"phpbench/phpbench": "~0.3.0"
"phpbench/phpbench": "dev-master"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 0 additions & 7 deletions config/phpbench → config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,3 @@
}

require_once($cwd . '/tests/bootstrap.php');

$config = new PhpBench\Configuration();
$config->setPath(__DIR__ . '/../benchmarks');

require_once('report.php');

return $config;
29 changes: 29 additions & 0 deletions config/phpbench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"bootstrap": "./bootstrap.php",
"path": "../benchmarks",
"reports": {
"insert": {
"extends": "aggregate",
"title": "Inserting Nodes",
"description": "Insert nodes into the repository as children of a single parent",
"params": {"selector": "//subject[group[@name='insert']]//variant"}
},
"query_select_one": {
"extends": "aggregate",
"title": "Query, selecting one property",
"description": "Execute a SELECT query, selecting a single property: SELECT someprop FROM [nt:unstructured]",
"params": {"selector": "//subject[group[@name='query_single_prop']]" }
},
"query_variable_props": {
"extends": "aggregate",
"title": "Query, variable properties",
"description": " Execute a SELECT query with an increasing number of properties: SELECT [prop1, prop2, prop3, ...] FROM [nt:unstructured]",
"params": {"selector": "//subject[group[@name='query_variable_props']]/variant" }
},
"full_tree_traversal": {
"extends": "aggregate",
"title": "Full Tree Traversal",
"params": {"selector": "//subject[group[@name='traversal_full']]//variant" }
}
}
}
55 changes: 0 additions & 55 deletions config/report.php

This file was deleted.