diff --git a/bench-read.php b/bench-read.php index f791bdf..8ad28ff 100644 --- a/bench-read.php +++ b/bench-read.php @@ -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; diff --git a/bench-write.php b/bench-write.php index afb656e..28328d0 100644 --- a/bench-write.php +++ b/bench-write.php @@ -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; diff --git a/src/Csv/Native.php b/src/Csv/Native.php index c2e76b4..02469ce 100644 --- a/src/Csv/Native.php +++ b/src/Csv/Native.php @@ -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 { @@ -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);