Skip to content

Commit 2571b16

Browse files
committed
wip
1 parent 47c046c commit 2571b16

File tree

8 files changed

+212
-218
lines changed

8 files changed

+212
-218
lines changed

benchmark/benchmark/NodeBench.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use PhpBench\Attributes as Bench;
88
use Syndesi\CypherDataStructures\Type\Node;
9-
use Syndesi\CypherDataStructures\Type\NodeLabel;
10-
use Syndesi\CypherDataStructures\Type\PropertyName;
119

1210
class NodeBench
1311
{
@@ -32,16 +30,16 @@ public function benchNodes(array $params): void
3230
{
3331
$nodes = [];
3432
for ($i = 0; $i < $params[0]; ++$i) {
35-
$node = new Node();
36-
$node
37-
->addNodeLabel(new NodeLabel('LabelA'))
38-
->addNodeLabel(new NodeLabel('LabelB'))
39-
->addProperty(new PropertyName('a'), 'some value for a')
40-
->addProperty(new PropertyName('b'), 'some value for b')
41-
->addProperty(new PropertyName('c'), 'some value for c')
42-
->addProperty(new PropertyName('d'), 'some value for d')
43-
->addProperty(new PropertyName('id'), rand())
44-
->addIdentifier(new PropertyName('id'));
33+
$node = (new Node())
34+
->addLabels(['LabelA', 'LabelB'])
35+
->addProperties([
36+
'a' => 'some value for a',
37+
'b' => 'some value for b',
38+
'c' => 'some value for c',
39+
'd' => 'some value for d',
40+
'id' => rand()
41+
])
42+
->addIdentifier('id');
4543
$nodes[] = $node;
4644
}
4745
}

benchmark/benchmark/RelationBench.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
use PhpBench\Attributes as Bench;
88
use Syndesi\CypherDataStructures\Type\Node;
9-
use Syndesi\CypherDataStructures\Type\NodeLabel;
10-
use Syndesi\CypherDataStructures\Type\PropertyName;
119
use Syndesi\CypherDataStructures\Type\Relation;
12-
use Syndesi\CypherDataStructures\Type\RelationType;
1310

1411
class RelationBench
1512
{
@@ -34,29 +31,28 @@ public function benchRelations(array $params): void
3431
{
3532
$relations = [];
3633
for ($i = 0; $i < $params[0]; ++$i) {
37-
$startNode = new Node();
38-
$startNode
39-
->addNodeLabel(new NodeLabel('StartNode'))
40-
->addProperty(new PropertyName('id'), rand())
41-
->addIdentifier(new PropertyName('id'));
34+
$startNode = (new Node())
35+
->addLabel('StartNode')
36+
->addProperty('id', rand())
37+
->addIdentifier('id');
4238

43-
$endNode = new Node();
44-
$endNode
45-
->addNodeLabel(new NodeLabel('EndNode'))
46-
->addProperty(new PropertyName('id'), rand())
47-
->addIdentifier(new PropertyName('id'));
39+
$endNode = (new Node())
40+
->addLabel('StartNode')
41+
->addProperty('id', rand())
42+
->addIdentifier('id');
4843

49-
$relation = new Relation();
50-
$relation
44+
$relation = (new Relation())
5145
->setStartNode($startNode)
5246
->setEndNode($endNode)
53-
->setRelationType(new RelationType('TYPE'))
54-
->addProperty(new PropertyName('id'), rand())
55-
->addProperty(new PropertyName('a'), 'some value for a')
56-
->addProperty(new PropertyName('b'), 'some value for b')
57-
->addProperty(new PropertyName('c'), 'some value for c')
58-
->addProperty(new PropertyName('d'), 'some value for d')
59-
->addIdentifier(new PropertyName('id'));
47+
->setType('TYPE')
48+
->addProperties([
49+
'a' => 'some value for a',
50+
'b' => 'some value for b',
51+
'c' => 'some value for c',
52+
'd' => 'some value for d',
53+
'id' => rand()
54+
])
55+
->addIdentifier('id');
6056
$relations[] = $relation;
6157
}
6258
}

benchmark/benchmarks.csv

Lines changed: 181 additions & 181 deletions
Large diffs are not rendered by default.

docs/assets/nodes_memory.png

1.85 KB
Loading

docs/assets/nodes_time.png

2.87 KB
Loading

docs/assets/relations_memory.png

981 Bytes
Loading

docs/assets/relations_time.png

-1.4 KB
Loading

docs/benchmark.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ optimized setup etc. the performance should increase quite a bit.
77
## Node
88

99
Time and memory increase linearly with the amount of instances created.
10-
An average node with two labels, four string properties and an integer id requires ~2kb of memory and is created within
11-
~0.02 ms
10+
An average node with two labels, four string properties and an integer id requires ~1.2kb of memory and is created
11+
within ~0.002 ms
1212

1313
![Plot of number of nodes vs time](./assets/nodes_time.png)
1414
![Plot of number of nodes vs memory](./assets/nodes_memory.png)
@@ -17,7 +17,7 @@ An average node with two labels, four string properties and an integer id requir
1717

1818
Time and memory increase linearly with the amount of instances created.
1919
An average relation with two minimal nodes (one label, one integer id), one type, four string properties and one integer
20-
id requires ~5.5kb of memory and is created within ~0.04ms.
20+
id requires ~3.3kb of memory and is created within ~0.006ms.
2121

2222
![Plot of number of relations vs time](./assets/relations_time.png)
2323
![Plot of number of relations vs memory](./assets/relations_memory.png)

0 commit comments

Comments
 (0)