1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__serveur-vote-lalis/include/condorcet/Benchmarks/PairwiseUpdateOptimizationBench.php

41 lines
868 B
PHP
Raw Normal View History

2022-09-21 12:39:11 +02:00
<?php
declare(strict_types=1);
namespace CondorcetPHP\Condorcet\Benchmarks;
use CondorcetPHP\Condorcet\Election;
use PhpBench\Attributes as Bench;
class PairwiseUpdateOptimizationBench
{
#[Bench\Warmup(1)]
#[Bench\Iterations(2)]
#[Bench\Revs(4)]
public function benchPairwiseOptimization(): void
{
$election = new Election;
$election->parseCandidates('A;B;C;D;E;F;G');
$election->parseVotes('
E > B > C > A > G * 2500
F > B > G > H > A * 2500
H > B > G > E > A * 2500
A = B = C > D > E = F > G * 2500
G = E = C > F > A * 2500
C > D = G > A > B * 2500
');
$election->getWinner();
$vote = $election->addVote('A>B>C');
$election->removeVote($vote);
$vote->setRanking('C>B>A');
$election->getWinner();
}
}