I'm new to Julia, and I wrote a simple function that calculates RMSE (standard error). ratings is a rating matrix, each line [user, film, rating] . There are 15 million ratings. The rmse() method takes 12.0 s, but the Java implementation is about 188 times faster: 0.064 s. Why is Julia's implementation slowing down? In Java, I work with an array of Rating objects, if it was a multi-dimensional int array, it will be even faster.
ratings = readdlm("ratings.dat", Int32) function predict(user, film) return 3.462 end function rmse() total = 0.0 for i in 1:size(ratings, 1) r = ratings[i,:] diff = predict(r[1], r[2]) - r[3] total += diff * diff end return sqrt(total / size(ratings)[1]) end
EDIT: After the global variable is excluded, it ends at 1.99 s (31 times slower than in Java). After removing r = ratings[i,:] it is equal to 0.856 s (13x slower).
performance julia-lang
fhucho
source share