Skip to content

Commit

Permalink
sort benchmark results
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Jan 3, 2024
1 parent 75f3f41 commit 5ad93f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bench-read.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@
}
}


foreach ($times as $format => $dataFormat) {
echo "Results for $format" . PHP_EOL;

$results = [];
foreach ($dataFormat as $class => $times) {
echo "$class : " . round(array_sum($times) / count($times), 4) . PHP_EOL;
$averageTime = round(array_sum($times) / count($times), 4);
$results[$class] = $averageTime;
}

uasort($results, fn ($a, $b) => $a <=> $b);
foreach ($results as $class => $averageTime) {
echo "$class : " . $averageTime . PHP_EOL;
}

echo PHP_EOL;
Expand Down
8 changes: 7 additions & 1 deletion bench-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@
echo "Results for $format" . PHP_EOL;

foreach ($dataFormat as $class => $times) {
echo "$class : " . round(array_sum($times) / count($times), 4) . PHP_EOL;
$averageTime = round(array_sum($times) / count($times), 4);
$results[$class] = $averageTime;
}

uasort($results, fn($a, $b) => $a <=> $b);
foreach ($results as $class => $averageTime) {
echo "$class : " . $averageTime . PHP_EOL;
}

echo PHP_EOL;
Expand Down
3 changes: 3 additions & 0 deletions src/Csv/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/**
* This class allows you to read and write csv easily if you
* don't have League or OpenSpout installed
*
* It's also the fastest adapter as far as I can tell
*/
class Native extends CsvAdapter
{
Expand All @@ -20,6 +22,7 @@ public function readString(
...$opts
): Generator {
$this->configure(...$opts);

// check for bom
if (strncmp($contents, self::BOM, 3) === 0) {
$contents = substr($contents, 3);
Expand Down

0 comments on commit 5ad93f6

Please sign in to comment.