По мотивам:
http://livelog.wordpress.com/2008/11/23/fortran-vs-c-vs-python/
http://forum.vingrad.ru/index.php?showtopic=238902&view=findpost&p=1720822
Python 2.6:
import cmath
import time
s1=0
s2=0
s3=0
i=0
j=0
t3=0
t1 = time.time();
print t1;
for i in xrange(100):
for j in xrange(100):
s1=0.01+j
s2=0.02+i
s3=cmath.sin(i+j)
t2 = time.time();
t3 = t2-t1
print t3
print s3
print s1
print s2
J:
ts=: 6!:2 , 7!:2@]
f1=: 3 : 0 s1=.s2=.s3=.0
for_i. i.y do.
for_j. i.y do.
s1=.j+0.01
s2=.i+0.02
s3=.1&o.(j+i)
end.
end.
)
забъём оперативу:
f2=: 3 : 0 s1=.0.01+(+/~i.y)s2=.0.02+(+/~i.y)
s3=.1&o.(+/~i.y)
)
более мение норм:
f3=: 3 : 0
for_j. i.y do. s1=.0.01+j s2=.0.02+(i.y) s3=.1&o.(j+i.y) end. )
Результаты:Python:
3.09400010109J:
ts 'f1 1000'11.5336147471 12288
ts 'f2 1000'
0.152723879711 37755648
ts 'f3 1000'
0.0997285967909 48064