nyamsprod/csv-benchmarks

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

benchmark to compare famous PHP CSV libraries

0.2.0 2015-02-25 12:07 UTC

This package is not auto-updated.

Last update: 2021-09-18 00:19:32 UTC


README

Build Status Latest Version

As Nikita Popov once said:

Never trust a benchmark you didn't fake yourself.

While developping league\csv latest major version, I did some benchmarks against other well established CSV libraries in PHP to improve the package speed. Here's the code source, have fun with it !!

All CSV packages are managed by composer. Tested with the latest stable version

See the latest benchmark on Travis-CI

$  php bin/benchmark --rows=100 --iteration=10 --cells=10
CSV Benchmark
Runtime: 5.5.9-1ubuntu4.6
Host: Linux sogeking 3.13.0-46-generic #75-Ubuntu SMP Tue Feb 10 15:26:00 UTC 2015 i686
Packages tested: 7
Rows to be inserted/read: 100
Cells to be inserted/read: 1000
CSV document output: /var/www/csv-benchmarks/output/result.csv
Test Iteration: 10
---------------------------------------------------------------------------
| Package              | Version          | Test      | Avg Duration (MS) |
---------------------------------------------------------------------------
| filesystem functions | 5.5.9-1ubuntu4.6 | runWriter | 2,25              |
---------------------------------------------------------------------------
| filesystem functions | 5.5.9-1ubuntu4.6 | runReader | 2,5               |
---------------------------------------------------------------------------
| SplFileObject        | 5.5.9-1ubuntu4.6 | runWriter | 2,71              |
---------------------------------------------------------------------------
| SplFileObject        | 5.5.9-1ubuntu4.6 | runReader | 0,4               |
---------------------------------------------------------------------------
| box/spout            | 1.0.1            | runWriter | 2,85              |
---------------------------------------------------------------------------
| box/spout            | 1.0.1            | runReader | 6,02              |
---------------------------------------------------------------------------
| jwage/easy-csv       | 0.0.2            | runWriter | 3,05              |
---------------------------------------------------------------------------
| jwage/easy-csv       | 0.0.2            | runReader | 3,48              |
---------------------------------------------------------------------------
| goodby/csv           | 1.2.0            | runWriter | 7,05              |
---------------------------------------------------------------------------
| goodby/csv           | 1.2.0            | runReader | 5,84              |
---------------------------------------------------------------------------
| keboola/csv          | 1.1.3            | runWriter | 15,5              |
---------------------------------------------------------------------------
| keboola/csv          | 1.1.3            | runReader | 3,85              |
---------------------------------------------------------------------------
| league/csv           | 7.0.0            | runWriter | 3,64              |
---------------------------------------------------------------------------
| league/csv           | 7.0.0            | runReader | 2,61              |
---------------------------------------------------------------------------

Tested packages

Requirements

You need PHP >=5.5.0 or HHVM >= 3.2 to be sure the test will run. (PHP Generators as used to ease generating huge CSV documents).

Installation

$ composer require nyamsprod/csv-benchmarks

Usage

$ php bin/benchmark

Will display a help message with all the information needed.

Adding a new package

  • Make sure your csv package is available on packagist first
  • Clone this repo
  • Update the composer.json with the submitted package
$ composer require "myawesome/csv-package"
  • Add a new class in the src/Driver, for instance MyAwesomeCsvPackage directory that implements the CsvBenchmarks\Driver\Driver Interface.
    You can copy/paste an existing Driver to see how it works.
    Remember that the getName method must return the package name as registered with packagist. Following our example, it will be myawesome/csv-package.

  • Update the benchmark script by adding your new driver.

$drivers->add(new Driver\MyAwesomeCsvPackage());
  • If everything goes as planned you can submit your package via a Pull Request

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.