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/Dev/generate-large-vote-input_file.php

35 lines
597 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__.'/../__CondorcetAutoload.php';
///
$number_of_votes = 100_000_000;
$number_of_candidates = 8;
///
$candidateName = 'A';
$candidates = [];
for ($i=0; $i < $number_of_candidates; $i++) {
$candidates[] = $candidateName++;
}
$file = new \SplFileObject(__DIR__.'/large.votes', 'w+');
$cache = '';
for ($i=0; $i < $number_of_votes; $i++) {
shuffle($candidates);
$cache .= implode('>', $candidates)."\n";
if (mb_strlen($cache) > 5_000_000) {
$file->fwrite($cache);
$cache = '';
}
}
$file->fwrite($cache);