1. 18

  2. 8

    Now I’m curious about Rust.

    1. 7

      If I just port the fastest Go version to Rust, then it runs a little faster on my machine: https://gist.github.com/anonymous/39209470971ded73d40d26df143817f5

      I think the parameters for this benchmark aren’t that great, or at least, aren’t that useful. For example, replacing the use of a more generic map data structure (like a hash map) with a fixed size array seems like a major hack to me that probably doesn’t generalize well. What happens when the data set gets updated to include years more recent than 2009? Oops. Your program (as written in the blog post) will crash with an unsightly panic message.

      Something that’s more interesting to me is how fast the “easy solution” is. If I were writing this program for myself, I’d probably write it like this in Rust. If I compare that with the first Go program in the OP—which doesn’t even bother with a proper CSV parser—then the Go program is at least a few times slower on my machine.

      1. 2


      2. 5

        I’m sure @burntsushi could elaborate about his tool, xsv, that does this kind of thing. Bonus: he’s great at Go too, and so is possibly the best possible person to do such a comparison; I don’t know how many people have expertise at this specific intersection of technologies.

        1. 3

          What about C?!?

          1. 1

            Here is one written by mpu - https://github.com/mpu/faster-command-line-tools-in-nim/blob/master/C/fast.c

            Knowing him, I think it will probably perform quite nicely compared to these.

            1. 0

              I’m sure C will smoke them all.

              1. 7

                At this point in development, if Rust is considerably slower than equivalent C, we consider it a bug. That said, there are some out there! This task is likely to hit one of those, I’d think: SIMD.

          2. 1

            I am not a Ruby programmer at all, but recently made the claim that Ruby is probably faster than Python on average tasks (based on micro benchmarks I’ve seen). So I got curious and made a pretty much 1:1 conversion of the Python code to Ruby. On my local machine the Python 2 and 3 interpreters both take 32 CPU seconds (only difference being print parentheses there) and the Ruby one takes 25 seconds.