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/KemenyYoungBench.php

48 lines
1.1 KiB
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\Algo\Methods\KemenyYoung\KemenyYoung;
use CondorcetPHP\Condorcet\Election;
use PhpBench\Attributes as Bench;
ini_set('memory_limit', '51200M');
// Must use --executor=memory_centric_microtime
class KemenyYoungBench
{
public function __construct()
{
KemenyYoung::$MaxCandidates = 10;
}
public function provideCandidatesCount(): \Generator
{
for ($i = 1; $i <= 10; $i++) {
yield $i => ['candidatesCount' => $i];
}
}
#[Bench\ParamProviders(['provideCandidatesCount'])]
#[Bench\OutputTimeUnit('milliseconds')]
#[Bench\Warmup(1)]
#[Bench\Iterations(3)]
#[Bench\Revs(4)]
public function benchKemenyYoung(array $params): void
{
$election = new Election;
for ($i = 0; $i < $params['candidatesCount']; $i++) {
$candidates[] = $election->addCandidate();
}
$election->addVote($candidates);
$result = $election->getResult('KemenyYoung');
}
}