aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-x[-rw-r--r--]bench.rb8
-rw-r--r--cr-test.cr16
-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
diff --git a/bench.rb b/bench.rb
index e34bcda..83f4113 100644..100755
--- a/bench.rb
+++ b/bench.rb
@@ -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
diff --git a/csv-test.py b/py-test.py
index 0662965..0662965 100644
--- a/csv-test.py
+++ b/py-test.py
diff --git a/csv-test.rb b/rb-test.rb
index c0e43c0..973c8cf 100644
--- a/csv-test.rb
+++ b/rb-test.rb
@@ -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