Simon, Thanks for the explanation! In Java int is 32 bit as well. I have just replaced ints with longs in Java and found out that now I get the Java speed also very similar to Julia.
However I tried in Cython: def primes_list(int kmax): cdef int k, i cdef long n cdef long p[20000] ... and surprisingly the speed did not change...at first I thought that maybe something did not compile or is in cache - but I made sure - it's not the cache. Cython speed remains unchanged regardles using int or long? I know that now it becomes other language question...but maybe someone can explain? All best, Przemyslaw Szufel On Tuesday, 14 January 2014 23:29:40 UTC+1, Simon Kornblith wrote: > > With a 64-bit build, Julia integers are 64-bit unless otherwise specified. > In C, you use ints, which are 32-bit. Changing them to long long makes the > C code perform similarly to the Julia code on my system. Unfortunately, > it's hard to operate on 32-bit integers in Julia, since + promotes to > 64-bit by default (am I missing something)? > > Simon > > On Tuesday, January 14, 2014 4:32:16 PM UTC-5, Przemyslaw Szufel wrote: >> >> Dear Julia users, >> >> I am considering using Julia for computational projects. >> As a first to get a feeling of the new language a I tried to benchmark >> Julia speed against other popular languages. >> I used an example code from the Cython tutorial: >> http://docs.cython.org/src/tutorial/cython_tutorial.html [ the code for >> finding n first prime numbers]. >> >> Rewriting the code in different languages and measuring the times on my >> Windows laptop gave me the following results: >> >> Language | Time in seconds (less=better) >> >> Python: 65.5 >> Cython (with MinGW): 0.82 >> Java : 0.64 >> Java (with -server option) : 0.64 >> C (with MinGW): 0.64 >> Julia (0.2): 2.1 >> Julia (0.3 nightly build): 2.1 >> >> All the codes for my experiments are attached to this post (Cython i >> Python are both being run starting from the prim.py file) >> >> The thing that worries me is that Julia takes much much longer than >> Cython ,,, >> I am a beginner to Julia and would like to kindly ask what am I doing >> wrong with my code. >> I start Julia console and use the command include ("prime.jl") to >> execute it. >> >> This code looks very simple and I think the compiler should be able to >> optimise it to at least the speed of Cython? >> Maybe I my code has been written in non-Julia style way and the compiler >> has problems with it? >> >> I will be grateful for any answers or comments. >> >> Best regards, >> Przemyslaw Szufel >> >