Hacker News new | past | comments | ask | show | jobs | submit login

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



I 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)


No, it was compiled but without --release as I couldn't get it working on OS X Sierra.


This 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: