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 Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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');
}
}