election = $election = new Election; $this->election->setNumberOfSeats(max(1, (int) ($numberOfCandidates / 3))); $this->election->setStatsVerbosity(StatsVerbosity::STD); $candidates = []; for ($i=0; $i < $numberOfCandidates; $i++) { $candidates[] = $election->addCandidate(); } for ($i = 0; $i < $numberOfVotes; $i++) { $oneVote = $randomizer->shuffleArray($candidates); $election->addVote($oneVote); } } public function provideMethods(): \Generator { foreach (Condorcet::getAuthMethods() as $method) { $class = Condorcet::getMethodClass($method); if ($class::IS_PROPORTIONAL === $this->IS_A_PROPORTIONAL_BENCH) { yield $method => ['method' => $method]; } } } public function provideNumberOfCandidates(): \Generator { foreach ($this->numberOfCandidates as $n) { yield $n => ['numberOfCandidates' => $n]; } } public function setUp(array $params): void { $this->buildElection($params['numberOfCandidates'], 1_000); } #[Bench\OutputTimeUnit('seconds')] #[Bench\ParamProviders(['provideMethods', 'provideNumberOfCandidates'])] #[Bench\BeforeMethods('setUp')] #[Bench\Warmup(1)] #[Bench\Iterations(3)] #[Bench\Revs(1)] public function benchByCandidates(array $params): void { try { $result = $this->election->getResult($params['method']); } catch (MethodLimitReachedException $e) { } $this->election->cleanupCalculator(); } }