benchmark/parse.yaml

Summary

Maintainability
Test Coverage
loop_count: 100
contexts:
  - gems:
      csv: 3.0.1
  - gems:
      csv: 3.0.2
  - name: "master"
    prelude: |
      $LOAD_PATH.unshift(File.expand_path("lib"))
      require "csv"
prelude: |-
  n_columns = Integer(ENV.fetch("N_COLUMNS", "50"), 10)
  n_rows = Integer(ENV.fetch("N_ROWS", "1000"), 10)
  alphas = ["AAAAA"] * n_columns
  unquoted = (alphas.join(",") + "\r\n") * n_rows
  quoted = (alphas.map { |s| %("#{s}") }.join(",") + "\r\n") * n_rows
  mixed = (alphas.map.with_index { |s, i| i.odd? ? s : %("#{s}") }.join(",") + "\r\n") * n_rows
  inc_col_sep = (alphas.map { |s| %(",#{s}") }.join(",") + "\r\n") * n_rows
  inc_row_sep = (alphas.map { |s| %("#{s}\r\n") }.join(",") + "\r\n") * n_rows
  hiraganas = ["あああああ"] * n_columns
  enc_utf8 = (hiraganas.join(",") + "\r\n") * n_rows
  enc_sjis = enc_utf8.encode("Windows-31J")
benchmark:
  unquoted: CSV.parse(unquoted)
  quoted: CSV.parse(quoted)
  mixed: CSV.parse(mixed)
  include_col_sep: CSV.parse(inc_col_sep)
  include_row_sep: CSV.parse(inc_row_sep)
  encode_utf-8: CSV.parse(enc_utf8)
  encode_sjis: CSV.parse(enc_sjis)