3 ms·
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 -
by supersillyus 15y ago
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 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.)
- supersillyus 15y agoAh. 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 http://pastie.org/2202611 Time: 0m0.796s
- ttsiodras 15y agoCommitted to the repository - thanks!
- supersillyus 15y agoAh. 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 http://pastie.org/2202963 May want to use that instead.
- ttsiodras 15y agoAdded it, thanks.