Created
January 28, 2015 14:09
-
-
Save nyamsprod/554deb252fb2835a4a9a to your computer and use it in GitHub Desktop.
Benchmark for league Csv 6.4+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use League\Csv\Writer; | |
| function generateRawData($start, $end) | |
| { | |
| for ($i = $start; $i < $end; $i++) { | |
| $index = $i; | |
| yield [ | |
| 'cell--'.($index), | |
| 'cell--'.($index+1), | |
| 'cell--'.($index+2), | |
| ]; | |
| } | |
| } | |
| $start = microtime(true); | |
| $nbrows = 200000; | |
| $csv = Writer::createFromPath('result.csv', 'w'); //to work make sure you have the write permission | |
| $csv->useValidation(false); //disable row validation | |
| $csv->insertAll(generateRawData(0, $nbrows)); | |
| $duration = microtime(true) - $start; | |
| $memory = memory_get_peak_usage(true); | |
| echo 'adding '. $nbrows, ' rows in ', $duration, ' seconds using ', $memory, ' bytes', PHP_EOL; | |
| die(0); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By disabling the content validation. we gain a major boost.
For
200000rows:with validationit tooks16.26swithout validationit tooks3.9sSet up
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:42)model name : Intel(R) Core(TM)2 Duo CPU E7200 @ 2.53GHz