Skip to content

Commit c4d975d

Browse files
authored
Merge pull request #3 from jspeedz/dev
Benchmarking + disable dependency matrix testing
2 parents 17b1c10 + 7ff6d58 commit c4d975d

File tree

4 files changed

+1709
-1043
lines changed

4 files changed

+1709
-1043
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
php:
1515
- "8.2"
1616
- "8.3"
17-
dependencies:
18-
- "lowest"
19-
- "highest"
17+
# dependencies:
18+
# - "lowest"
19+
# - "highest"
2020
include:
2121
- php-version: "8.3"
2222
composer-options: "--ignore-platform-reqs"
@@ -30,7 +30,7 @@ jobs:
3030
- name: Composer install
3131
uses: "ramsey/composer-install@v3"
3232
with:
33-
dependency-versions: "${{ matrix.dependencies }}"
33+
# dependency-versions: "${{ matrix.dependencies }}"
3434
composer-options: "${{ matrix.composer-options }}"
3535

3636
- name: PHPStan static analysis

benchmarking/benchmark.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
echo 'Available hash algos: ' . implode(', ', hash_algos()) . PHP_EOL . PHP_EOL;
3232

3333
// How many data points do we generate?
34-
$dataCount = 35000;
34+
$dataCount = 25000;
3535
// How many times do we re-generate the data and re-hash it?
3636
$dataIterations = 10;
3737

@@ -49,6 +49,19 @@
4949
'node2' => 30,
5050
'node3' => 50,
5151
],
52+
'15 15 25 45' => [
53+
'node1' => 15,
54+
'node2' => 15,
55+
'node3' => 25,
56+
'node4' => 45,
57+
],
58+
'50 20 20 5 5' => [
59+
'node1' => 50,
60+
'node2' => 20,
61+
'node3' => 20,
62+
'node4' => 5,
63+
'node5' => 5,
64+
],
5265
'25 25 25 25' => [
5366
'node1' => 100/4,
5467
'node2' => 100/4,
@@ -112,7 +125,7 @@
112125
'node9' => 100/10,
113126
'node10' => 100/10,
114127
],
115-
'11 11 11 11 11 11 11 11 11 11 11' => [
128+
'9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09' => [
116129
'node1' => 100/11,
117130
'node2' => 100/11,
118131
'node3' => 100/11,
@@ -125,18 +138,11 @@
125138
'node10' => 100/11,
126139
'node11' => 100/11,
127140
],
128-
'15 15 25 45' => [
129-
'node1' => 15,
130-
'node2' => 15,
131-
'node3' => 25,
132-
'node4' => 45,
133-
],
134-
'50 20 20 5 5' => [
135-
'node1' => 50,
136-
'node2' => 20,
137-
'node3' => 20,
138-
'node4' => 5,
139-
'node5' => 5,
141+
'3 1 5 1' => [
142+
'node1' => 3,
143+
'node2' => 1,
144+
'node3' => 5,
145+
'node4' => 1,
140146
],
141147
'1 1' => [
142148
'node1' => 1,
@@ -280,8 +286,17 @@
280286
$time = (microtime(true) - $time) * 1000;
281287

282288
$total = array_sum($distribution);
289+
290+
// Convert the weights to an expected percentage of the total distribution
291+
$nodeDistributionTotalWeight = array_sum($nodeDistribution);
292+
$nodeDistributionPercentages = [];
293+
foreach($nodeDistribution as $nodeName => $weight) {
294+
$nodeDistributionPercentages[$nodeName] = $weight * 100 / $nodeDistributionTotalWeight;
295+
}
296+
297+
// Calculate the deviation from the perfect distribution percentage
283298
foreach($distribution as $nodeName => &$count) {
284-
$count = abs($nodeDistribution[$nodeName] - ($count / $total * 100));
299+
$count = abs($nodeDistributionPercentages[$nodeName] - ($count / $total * 100));
285300
}
286301

287302
$totalIterationDeviation = array_sum($distribution);

0 commit comments

Comments
 (0)