diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | bench.rb | 8 | ||||
-rw-r--r-- | cr-test.cr | 16 | ||||
-rw-r--r-- | py-test.py (renamed from csv-test.py) | 0 | ||||
-rw-r--r-- | rb-test.rb (renamed from csv-test.rb) | 2 |
5 files changed, 24 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72699f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/*.csv @@ -4,10 +4,14 @@ require 'benchmark' Benchmark.bm(5) do |bm| bm.report('python') do - `python2.7 ./csv-test.py test.csv out.csv` + `python2.7 ./py-test.py test.csv out.csv` end bm.report('ruby') do - `ruby ./csv-test.rb test.csv out.csv` + `ruby ./rb-test.rb test.csv out.csv` + end + + bm.report('crystal') do + `./cr-test test.csv out.csv` end end diff --git a/cr-test.cr b/cr-test.cr new file mode 100644 index 0000000..18c6580 --- /dev/null +++ b/cr-test.cr @@ -0,0 +1,16 @@ +# build: crystal build --release cr-test.cr + +require "csv" + +# get paths +src_path, dst_path = ARGV + +File.open(src_path, "rb") do |src_io| + File.open(dst_path, "wb") do |dst_io| + CSV.build(dst_io) do |dst| + CSV.each_row(src_io) do |row| + dst.row(row += (%w{foo} * 2)) + end + end + end +end @@ -7,6 +7,6 @@ src_path, dst_path = ARGV CSV.open(dst_path, 'wb') do |dst| CSV.foreach(src_path) do |row| - dst << row + %w{foo} * 2 + dst << (row += %w{foo} * 2) end end |