Skip to content

Commit 4f7676d

Browse files
committed
Merge pull request #2 from phpcr/latest_phpbench
Refactoring to latest phpbench
2 parents 4c14420 + a831e9d commit 4f7676d

File tree

9 files changed

+51
-96
lines changed

9 files changed

+51
-96
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ composer require "phpcr/phpcr-benchmarks"
1818
Run:
1919

2020
````bash
21-
$ ./vendor/bin/phpbench run --config=vendor/phpcr/phpcr-benchmarks/config/phpbench
21+
$ ./vendor/bin/phpbench run --config=vendor/phpcr/phpcr-benchmarks/config/phpbench.json
2222
````
2323

2424
For more information see the documentation for [PHPBench](https://github.com/phpbench/phpbench).

benchmarks/BaseBench.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace PHPCR\Benchmark;
44

55
use PHPCR\NodeInterface;
6-
use PhpBench\Benchmark;
6+
use PhpBench\BenchmarkInterface;
77
use PHPCR\ImportUUIDBehaviorInterface;
88

9-
abstract class BaseBench implements Benchmark
9+
abstract class BaseBench implements BenchmarkInterface
1010
{
1111
const ROOT_NAME = 'bench';
1212
const ROOT_PATH = '/bench';

benchmarks/InsertBench.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@
88

99
/**
1010
* @group insert
11-
* @processIsolation iteration
11+
* @iterations 4
12+
* @revs 4
1213
*/
1314
class InsertBench extends BaseBench
1415
{
16+
private $index = 1;
17+
1518
/**
16-
* @description Insert nodes
1719
* @paramProvider provideNbNodes
1820
* @beforeMethod beforeResetWorkspace
19-
* @iterations 2
2021
*/
21-
public function benchInsertNodes(Iteration $iteration)
22+
public function benchInsertNodes($params)
2223
{
23-
$this->createNodes($this->getRootNode(), $iteration->getParameter('nb_nodes'), array(
24+
$this->createNodes($this->getRootNode(), $params['nb_nodes'], array(
2425
'string' => 'Hello',
2526
'number' => 10,
2627
'hello' => 'goodbye',
2728
'goodbye' => 'hello',
28-
), 0);
29+
), $this->index * $params['nb_nodes']);
30+
$this->index++;
2931

3032
$this->getSession()->save();
3133
}

benchmarks/QueryBench.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
/**
99
* @group query
10-
* @processIsolation iteration
1110
*/
1211
class QueryBench extends BaseBench
1312
{
@@ -17,26 +16,24 @@ public function setUp()
1716
}
1817

1918
/**
20-
* @description No iterations
2119
* @paramProvider provideQueries
2220
* @iterations 5
2321
* @group query_single_prop
2422
*/
25-
public function benchQuery(Iteration $iteration)
23+
public function benchQuery($params)
2624
{
27-
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
25+
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
2826
$query->execute();
2927
}
3028

3129
/**
32-
* @description Retrive nodes for each row
3330
* @paramProvider provideQueries
3431
* @iterations 5
3532
* @group query_single_prop
3633
*/
37-
public function benchQueryWithNodes(Iteration $iteration)
34+
public function benchQueryWithNodes($params)
3835
{
39-
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
36+
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
4037
$results = $query->execute();
4138

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

4744
/**
48-
* @description Iterate over rows and retrieve properties
4945
* @paramProvider provideQueries
5046
* @iterations 5
5147
* @group query_single_prop
5248
*/
53-
public function benchQueryIterate(Iteration $iteration)
49+
public function benchQueryIterate($params)
5450
{
55-
$query = $this->getQueryManager()->createQuery($iteration->getParameter('query'), 'JCR-SQL2');
51+
$query = $this->getQueryManager()->createQuery($params['query'], 'JCR-SQL2');
5652
$results = $query->execute();
5753

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

6359
/**
64-
* @description Run a select query with variable amount of properties
6560
* @paramProvider provideProperties
6661
* @iterations 5
6762
* @group query_variable_props
6863
*/
69-
public function benchQueryIterateVariableProperties(Iteration $iteration)
64+
public function benchQueryIterateVariableProperties($params)
7065
{
71-
$props = $iteration->getParameter('props');
66+
$props = $params['props'];
7267
$query = $this->getQueryManager()->createQuery(sprintf(
7368
'SELECT %s FROM [nt:unstructured] WHERE valves IS NOT NULL'
7469
, implode(', ', $props)), 'JCR-SQL2');

benchmarks/TraversalBench.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use PHPCR\NodeInterface;
66

77
/**
8-
* @processIsolation iteration
8+
* @group traversal_full
9+
* @iterations 6
910
*/
1011
class TraversalBench extends BaseBench
1112
{
@@ -14,21 +15,11 @@ public function setUp()
1415
$this->loadDump('large_website.xml');
1516
}
1617

17-
/**
18-
* @description Full traversal
19-
* @group traversal_full
20-
* @iterations 3
21-
*/
2218
public function benchFullTraversal()
2319
{
2420
$this->traverse($this->getSession()->getRootNode());
2521
}
2622

27-
/**
28-
* @description Full traversal and read all properties
29-
* @group traversal_full
30-
* @iterations 3
31-
*/
3223
public function benchFullTraversalReadProperties()
3324
{
3425
$this->traverse($this->getSession()->getRootNode(), true);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"minimum-stability": "dev",
1212
"require": {
13-
"phpbench/phpbench": "~0.3.0"
13+
"phpbench/phpbench": "dev-master"
1414
},
1515
"autoload": {
1616
"psr-4": {

config/phpbench renamed to config/bootstrap.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,3 @@
2222
}
2323

2424
require_once($cwd . '/tests/bootstrap.php');
25-
26-
$config = new PhpBench\Configuration();
27-
$config->setPath(__DIR__ . '/../benchmarks');
28-
29-
require_once('report.php');
30-
31-
return $config;

config/phpbench.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"bootstrap": "./bootstrap.php",
3+
"path": "../benchmarks",
4+
"reports": {
5+
"insert": {
6+
"extends": "aggregate",
7+
"title": "Inserting Nodes",
8+
"description": "Insert nodes into the repository as children of a single parent",
9+
"params": {"selector": "//subject[group[@name='insert']]//variant"}
10+
},
11+
"query_select_one": {
12+
"extends": "aggregate",
13+
"title": "Query, selecting one property",
14+
"description": "Execute a SELECT query, selecting a single property: SELECT someprop FROM [nt:unstructured]",
15+
"params": {"selector": "//subject[group[@name='query_single_prop']]" }
16+
},
17+
"query_variable_props": {
18+
"extends": "aggregate",
19+
"title": "Query, variable properties",
20+
"description": " Execute a SELECT query with an increasing number of properties: SELECT [prop1, prop2, prop3, ...] FROM [nt:unstructured]",
21+
"params": {"selector": "//subject[group[@name='query_variable_props']]/variant" }
22+
},
23+
"full_tree_traversal": {
24+
"extends": "aggregate",
25+
"title": "Full Tree Traversal",
26+
"params": {"selector": "//subject[group[@name='traversal_full']]//variant" }
27+
}
28+
}
29+
}

config/report.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)