Skip to content

Commit

Permalink
Merge pull request #3 from jspeedz/dev
Browse files Browse the repository at this point in the history
Benchmarking + disable dependency matrix testing
  • Loading branch information
jspeedz authored Jul 12, 2024
2 parents 17b1c10 + 7ff6d58 commit c4d975d
Show file tree
Hide file tree
Showing 4 changed files with 1,709 additions and 1,043 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
php:
- "8.2"
- "8.3"
dependencies:
- "lowest"
- "highest"
# dependencies:
# - "lowest"
# - "highest"
include:
- php-version: "8.3"
composer-options: "--ignore-platform-reqs"
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Composer install
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
# dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"

- name: PHPStan static analysis
Expand Down
45 changes: 30 additions & 15 deletions benchmarking/benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
echo 'Available hash algos: ' . implode(', ', hash_algos()) . PHP_EOL . PHP_EOL;

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

Expand All @@ -49,6 +49,19 @@
'node2' => 30,
'node3' => 50,
],
'15 15 25 45' => [
'node1' => 15,
'node2' => 15,
'node3' => 25,
'node4' => 45,
],
'50 20 20 5 5' => [
'node1' => 50,
'node2' => 20,
'node3' => 20,
'node4' => 5,
'node5' => 5,
],
'25 25 25 25' => [
'node1' => 100/4,
'node2' => 100/4,
Expand Down Expand Up @@ -112,7 +125,7 @@
'node9' => 100/10,
'node10' => 100/10,
],
'11 11 11 11 11 11 11 11 11 11 11' => [
'9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09 9.09' => [
'node1' => 100/11,
'node2' => 100/11,
'node3' => 100/11,
Expand All @@ -125,18 +138,11 @@
'node10' => 100/11,
'node11' => 100/11,
],
'15 15 25 45' => [
'node1' => 15,
'node2' => 15,
'node3' => 25,
'node4' => 45,
],
'50 20 20 5 5' => [
'node1' => 50,
'node2' => 20,
'node3' => 20,
'node4' => 5,
'node5' => 5,
'3 1 5 1' => [
'node1' => 3,
'node2' => 1,
'node3' => 5,
'node4' => 1,
],
'1 1' => [
'node1' => 1,
Expand Down Expand Up @@ -280,8 +286,17 @@
$time = (microtime(true) - $time) * 1000;

$total = array_sum($distribution);

// Convert the weights to an expected percentage of the total distribution
$nodeDistributionTotalWeight = array_sum($nodeDistribution);
$nodeDistributionPercentages = [];
foreach($nodeDistribution as $nodeName => $weight) {
$nodeDistributionPercentages[$nodeName] = $weight * 100 / $nodeDistributionTotalWeight;
}

// Calculate the deviation from the perfect distribution percentage
foreach($distribution as $nodeName => &$count) {
$count = abs($nodeDistribution[$nodeName] - ($count / $total * 100));
$count = abs($nodeDistributionPercentages[$nodeName] - ($count / $total * 100));
}

$totalIterationDeviation = array_sum($distribution);
Expand Down
Loading

0 comments on commit c4d975d

Please sign in to comment.