Julia is a new number crunching language that claims to have near c speed. On 
their homepage there is a set of benchmark to compare Julia with 
matlab/python/R etc. I made a try to add J into the table.Please see table 
below for my results. All programs runs on a windows 64 bit machine. My script 
enclosed at the end of this message.  Welcome to improve it since I dont have 
any practical experience on J other than toy exercises. 

Please see http://julialang.org/ for the offical Julia benchmarks, and links 
therein for source codes of other languages. (like 
https://github.com/JuliaLang/julia/blob/master/test/perf/perf.m for the matlab 
code.)



note that in the random matrix multiply test, J lags behind all other peers. 
The code I use is 

rand_nn =. 0 ?@$~ 2 # ]
mp =. +/ . *
randmatmul =. rand_nn mp rand_nn 
1000 * 6!:2 'randmatmul 1000'

I suspect that other languages use some library like BLAS for matrix rather 
than raw calculation.  Is there a way to speed up code above?

results:
in milsec Julia Matlab2013a R3.0.0 Python3.3+numpy(MKL) J801 
>fib <1 123 60 4 11 
>parse_int <1 163 10 5 7 
>mandel <1 13 230 8 47 
>quicksort <1 45 30 23 11 
>pi_sum 30 48 810 1192 64 
>rand_mat_stat 20 60 150 261 65 
>rand_mat_mul 210 216 880 90 1768 
>
>
>
>benchmark code:
>
>timeit =. 1000 * 6!:2
>
>>
>NB. double recursive fib.
>fib =. (-&2 +&$: -&1) ^: (1&<)
>
>>
>timeit 'fib 20'
>
>>
>NB. parse int
>parsintPerf =. 3 : 0
>for. i.y do.
>a =. ?<:2^32x
>s =. ":a
>b =. ".s
>assert b = a
>end.
>)
>
>>
>timeit 'parsintPerf 1000'
>
>>
>NB. mandel
>mandel =. 3 : 0
>c =. y
>m =. 0
>for_n. i.80 do.
>if. 2 <|y do. m =.n break. end.
>y =. c + *:y
>m =. n
>end.
>)
>
>>
>assert 14628 = +/+/ mandel"0 (_2 + 0.1*i.26) j./ (_1 + 0.1*i.21)
>timeit '+/+/ mandel"0 (_2 + 0.1*i.26) j./ (_1 + 0.1*i.21)'
>
>>
>NB. quicksort
>quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
>timeit 'quicksort ? 5000 $ 0'
>
>>
>NB. pi sum
>pisum =. 3 : 'for. i.500 do. +/ %*:>:i.y end.'
>assert '1e_12 > | _1.644834071848065 + pisum 10000'
>timeit 'pisum 10000'
>
>>
>NB. random matrix multiply.
>rand_nn =. 0 ?@$~ 2 # ]
>mp =. +/ . *
>randmatmul =. rand_nn mp rand_nn 
>timeit 'randmatmul 1000'
>
>>
>NB. rand mat stats/
>load 'stats/base'
>randn_nn =. [: normalrand 2 # ]
>trace =. [: +/ (<0 1)&|:
>randstats =. 3 : 0
>n =.5
>v =. 0
>w =. 0
>for. i.y do.
>a =. randn_nn n
>b =. randn_nn n
>c =. randn_nn n
>d =. randn_nn n
>P =. a,.b,.c,.d
>Q =. (a,.b),c,.d
>PP =. P mp |:P
>QQ =. Q mp |:Q
>v =.v, trace PP mp PP mp PP mp PP
>w =. w, trace QQ mp QQ mp QQ mp QQ
>end.
>((stddev % mean) v), ((stddev % mean) w)
>)
>
>>
>timeit 'randstats 1000'
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to