-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Rust and OCaml as a benchmark tests #1
Conversation
Also, what was go_port? It was not in an executable format, recompiled it.
Actually, if I don't mind, I'm adding OCaml as well, I'm especially curious in how OCaml and Rust compare for input/output speeds, hold off while I get it added right quick... |
Also added instructions for compiling the native code.
And updated with OCaml, as well as compilation instructions for the now 3 native code binaries. |
OCaml is 'almost' the fastest, and it has some of the best code it seems as well... Rust compiles more easily on Windows though, but OCaml can still be done on Windows easily enough... Interesting... |
Good stuff!
That's exactly what I did. I don't actually know if Go has an optimization flag.
That's a good point, I bet this is why Java performs so badly in the test. I made an issue for it: #2
Makes sense. Rust doesn't have any overhead in the form of a VM or garbage collector– in a toy program like this, it should be the undisputed king. Except maybe C.
The one currently on master is 2.4MB on my system. Maybe the win32 binaries are just bigger? On an unrelated note, I made another issue (#3) to build & run the benchmarks in Travis, since it's free anyway. That way we won't have to check in binaries at all. |
It compiled to the same size on both windows and linux for me, it seems it is just because Go is not able to optimize out its included standard library like most languages do. Rust's is large because it trims based on modules, not individual functions. I have no doubt I could get a C program down to a few kb at most (less if I did a little magic). :-) OCaml was nicely small however and still very fast, I was impressed at it. :-) And yeah, Travis would be good but do note that it is not consistent in speed, it depends on what else it is doing so you will not get reliable results. :-) |
It is not efficient Rust, I'm still learning it, but I was curious how it would do in the test so I added it, see the results on the updated README.md and below (I have a very old desktop, so I'm curious as to the results on your much newer system). I compiled the rust file with
rustc -C opt-level=3 rust_port.rs
, I have no idea how the go file was compiled so I had to recompile it for my system so I just did it viago compile go_port.go
or something like that.I have to admin, I'm impressed at just how slow java is, probably because it did not get a chance to warm up the JIT first. Any chance at spamming all the ports with about 100k messages to let everything warm up before the actual benchmarking starts because Java should not really be 'that' slow I'd think?
Interestingly though, with my very newbie level Rust, Rust blew away everything else. The only real thing I had to do to the rust code was lock stdout because the port was being killed before everything was flushed out properly on the last run, which was causing the last comparison tests to fail, but just
lock()
ing it fixed that (prevents the process from dying until stdout is fully flushed).I'm also surprised at how huge the go binary is. The Rust binary is not too small either (it has options that can reduce the size), but the go binary is just huge. o.O
Would you be curious in some other languages? I can toss in C/C++ and OCaml at least. I was just doing Rust currently as I was curious at how Rust itself acted by being a port (Rust can be a NIF as well, see the Rustler library).
My result on my extremely ancient test desktop:
Hmm, also those are supposed to be
µs
, guess that did not translate well via copy/pasting, will fix...EDIT: Updated above stats with OCaml too