Skip to content

Commit ba56df7

Browse files
committed
Add benchmark for Table#to_csv improvement
1 parent 4848dc2 commit ba56df7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

benchmark/table.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
loop_count: 100
2+
contexts:
3+
- gems:
4+
csv: 3.3.0
5+
- name: "master"
6+
prelude: |
7+
$LOAD_PATH.unshift(File.expand_path("lib"))
8+
require "csv"
9+
prelude: |-
10+
n_columns = Integer(ENV.fetch("N_COLUMNS", "5"), 10)
11+
n_rows = Integer(ENV.fetch("N_ROWS", "100"), 10)
12+
fields = ["AAAAA"] * n_columns
13+
headers = n_columns.times.collect do |i|
14+
"header#{i}"
15+
end
16+
row = CSV::Row.new(headers, fields)
17+
rows = [row] * n_rows
18+
table = CSV::Table.new(rows)
19+
rows = [row] * n_rows * 10
20+
large_table = CSV::Table.new(rows)
21+
benchmark:
22+
"to_csv: no encoding": |-
23+
table.to_csv
24+
"to_csv: encoding": |-
25+
table.to_csv(encoding: 'UTF-8')
26+
"to_csv: encoding - 10 x rows": |-
27+
large_table.to_csv(encoding: 'UTF-8')

0 commit comments

Comments
 (0)