for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace CondorcetPHP\Condorcet\Benchmarks;
use CondorcetPHP\Condorcet\Condorcet;
use CondorcetPHP\Condorcet\Election;
use CondorcetPHP\Condorcet\Candidate;
use CondorcetPHP\Condorcet\CondorcetUtil;
use CondorcetPHP\Condorcet\Vote;
class BasicUsageBench
{
/**
* @Iterations(2)
* @Warmup(1)
* @Revs(4)
*/
public function benchSimpleManyVotes () : void
$election = new Election;
$election->allowVoteWeight(true);
$election->parseCandidates('A;B;C;D;E;F');
$election->parseVotes('
Ultimate Question of Life || A>B>C ^42 * 42
C=A>B ^2 * 200
B>C
E > B > C > A ^80 *50
F > B > G > H > A* 250
D = B = E > F ^6 * 48
');
$election->getWinner();
$election->getLoser();
foreach (Condorcet::getAuthMethods() as $method) :
$election->getResult($method);
endforeach;
$election->setImplicitRanking(false);
$election->allowVoteWeight(false);
Ultimate Question of Life || C>B>A ^42 * 42
C=A=B ^2 * 200
A > C >E ^80 *50
G > B > G > H > F* 250
C = B = E > A ^6 * 48
$votes = $election->getVotesListAsString();
$votes
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
}
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.