项目作者: mschmo

项目描述 :
Python CFFI with rust CSV parser benchmarking
高级语言: Shell
项目地址: git://github.com/mschmo/cffi-bench.git
创建时间: 2017-04-08T04:24:47Z
项目社区:https://github.com/mschmo/cffi-bench

开源协议:

下载


Benching Python CFFI with Rust

Running

Download and build:

  1. $ git clone git@github.com:mschmo/cffi-bench.git
  2. $ cd cffi-bench
  3. $ sh build.sh

Then run bench tests with:

  1. $ sh run.sh

This will generate a CSV at /tmp/cffi_bench.csv with 5 million rows, then run time on the three row count implementations, output the results of the tests, and finally remove the CSV.

Results

Results are based on the process of counting the number of records in a 5M record CSV file.

On 16GB 1600 MHz DDR3, 2.8 GHz Intel Core i7 MacBook Pro:

  1. $ sh run.sh
  2. Generating test file at /tmp/cffi_bench.csv ...
  3. 5M record CSV created at /tmp/cffi_bench.csv
  4. Pure rust implementation:
  5. Records counted: 5000000
  6. real 0m0.613s
  7. user 0m0.577s
  8. sys 0m0.032s
  9. Python pandas implementation:
  10. Records counted: 5000000
  11. real 0m2.669s
  12. user 0m2.177s
  13. sys 0m0.469s
  14. Python CFFI with rust implementation:
  15. Records counted: 5000000
  16. real 0m0.741s
  17. user 0m0.689s
  18. sys 0m0.049s
  19. Cleaning up...
  20. Complete
Implementation Time
Pure rust 0.613s
Python2 CFFI with rust 0.741s
Python2 pandas 2.669s

Todo

  1. Do more than just count. Test processing like formatting rows, etc.
  2. Output results
  3. Expand beyond CSV