dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
767 stars 51 forks source link

Add benchmarks using benchee #76

Closed viniciusmuller closed 1 year ago

viniciusmuller commented 1 year ago

This pull request uses the already existing 10000_sales.csv file and adds some benchmarks using benchee for the ease of performance testing in development

$ mix run bench/benchmark.exs
Operating System: Linux
CPU Information: AMD Ryzen 7 5700X 8-Core Processor
Number of Available Cores: 16
Available memory: 31.26 GB
Elixir 1.14.4
Erlang 25.3.2

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 0 ns
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 21 s

Benchmarking 10k lines, 14 columns - NimbleCSV.RFC4180.parse_enumerable/1 ...
Benchmarking 10k lines, 14 columns - NimbleCSV.RFC4180.parse_stream/1 ...
Benchmarking 10k lines, 14 columns - NimbleCSV.RFC4180.parse_string/1 ...

Name                                                                   ips        average  deviation         median         99th %
10k lines, 14 columns - NimbleCSV.RFC4180.parse_enumerable/1         87.71       11.40 ms    ±10.27%       11.03 ms       16.41 ms
10k lines, 14 columns - NimbleCSV.RFC4180.parse_string/1             70.96       14.09 ms    ±11.61%       13.65 ms       20.89 ms
10k lines, 14 columns - NimbleCSV.RFC4180.parse_stream/1             18.35       54.49 ms    ±11.58%       51.62 ms       66.04 ms

Comparison:
10k lines, 14 columns - NimbleCSV.RFC4180.parse_enumerable/1         87.71
10k lines, 14 columns - NimbleCSV.RFC4180.parse_string/1             70.96 - 1.24x slower +2.69 ms
10k lines, 14 columns - NimbleCSV.RFC4180.parse_stream/1             18.35 - 4.78x slower +43.09 ms
josevalim commented 1 year ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: