Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For fun I did a trivial translation of the C++ version to Go.

Results (with gcc 4.2 -03 -mtune=native -DNDEBUG, head Go -B, Ocamlopt 3.12.0 -unsafe -rectypes -inline 1000):

C++: 0m0.611s

OCaml: 0m1.457s

Go: 0m1.043s

This is on a Macbook Pro 2.53 Ghz Core 2 Duo running OS X 10.5.8.

Go source: http://pastie.org/2199969

(With a trivial optimization, the Go version can be improved by ~13%, but I decided not to do that because it'd be a slightly different algorithm.)



Ah. Looks like he updated the C++ version to have the optimization I spoke of. So, here's the matching Go version: http://pastie.org/2202611

Time: 0m0.796s


Committed to the repository - thanks!


Ah. Ok then. I spent another few minutes with it after I posted that and made it a little nicer, but not particularly faster: http://pastie.org/2202963

May want to use that instead.


Added it, thanks.




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

Search: