Hi, Angel de Vicente <angel.vicente.garr...@gmail.com> writes: > OK, so this was just a test example to go for something bigger, and by > using the cleaner version with Nullable fields I implemented a basic > code to perform a Barnes-Hut N-body simulation > (https://en.wikipedia.org/wiki/Barnes%E2%80%93Hut_simulation) > > The good think is that it works OK, and development while being able to > use the REPL accelerates coding so much (in comparison to compiled > languages), but the bad news is that it is ~25x slower than my own > Fortran version :-( (I have tried to make all functions type stable and > I have followed the same algorithm as in the Fortran version).
after playing a little bit with the profiler, following some of the advice in http://docs.julialang.org/en/release-0.5/manual/performance-tips/ and doing some very minor changes to the code, these are the times (the best of three runs in all cases) for a test run of the code (100 time steps, 1000 bodies): Fortran: compiled with gfortran -O0 2.72s gfortran -O3 1.29s compiled with ifort -O0 4.73s ifort -O3 1.17s Julia: v.0.5 3.85s (first run ignored to avoid first compilation time) So my Julia version now takes ~3x the time of the Fortran one. Probably I could improve it even further, but given that I'm still very new to Julia this is not bad at all, I think. Good stuff! -- Ángel de Vicente http://www.iac.es/galeria/angelv/