3 ms·
Crystal is currently no faster than Ruby when parsing a 19Mb Apache log file on OS X Sierra: fh = File.open("logs1.txt") fh.each_line {|x| puts x if (/\b\w
by cutler 9y ago
Crystal is currently no faster than Ruby when parsing a 19Mb Apache log file on OS X Sierra:
fh = File.open("logs1.txt")
fh.each_line {|x| puts x if (/\b\w{15}\b/.match x) }
fh.close
- theodorton 9y agoI guess it depends, for one-off tasks you'll have to compile and run the Crystal code. I assume you ran the code above with `crystal run`. If you first compile the code with `crystal build --release` and run it, you should see a dramatic improvement over Ruby. On my machine, parsing a 374MB file took: - 25.63 using Ruby - 19.97 using Crystal (run w/o optimizations) - 19.01 using Crystal (compiled w/o optimizations) - 18.68 using Crystal (run w/ `--release` flag) - 11.54 using Crystal (compiled w/ `--release` flag)
- cutler 9y agoNo, it was compiled but without --release as I couldn't get it working on OS X Sierra.
- djur 9y agoThis isn't a benchmark that I'd expect to see a significant difference in. The majority of the CPU work is in the regular expression, and Ruby's regex engine is implemented in C.