|
So just how fast is MatBasic interpreter? This tiny example may give you some idea of the power in MatBasic.
function z=func(x,y)
z=sin(x)*sqrt(y)*0.01;
end
tic=tick();
y=0;
for(k=1:10000000)
y=y+func(k, k-10000000+1);
end
tick()-tic;
y; |
Output:
66.42
0.004205477932+28.93505816i
|
What do we have here? 10,000,000 iterations of a complex numbers operation and user function calls.
On an AMD 64-3000 CPU, MatBasic interpreter runs this loop in 66.42 seconds. MatBasic has been benchmarked favorably against
the same class of interpreter... MatLab.
Same computer, same operating system (WinXP Pro), no attempt to minimize any background tasks:
MatLab - 103.86 seconds.
% Matlab code
function z=func(x,y)
z=sin(x)*sqrt(y)*0.01;
end
tic;
y=0;
for(k=1:10000000)
y=y+func(k, k-10000000+1);
end
toc;
y; |
Output in a Matlab Command window:
>> elapsed_time =
103.8600
>> y
y =
0.0042 +28.9351i
>> |
Pretty respectable, we think.
|