From: Michal Kvasnicka on
Hi,

could anybody comment this terrible result of indexing benchmark: http://artax.karlin.mff.cuni.cz/~hajej2am/ulozna/benchmark_index.m

Matlab 2010a:
>> benchmark_index (4e6, 100)
time_slice1 = 5.734381
time_slice1s = 3.168516
time_slice1v = 9.452393
time_slice2c = 2.859510
time_slice2r = 6.575188
time_slice2cv = 2.765570
time_slice2rv = 7.077045
time_slicenc = 1.101543
time_slicend = 1.112965
time_slicens = 0.625092
time_slicen2 = 1.184789
time_spreadr = 5.156006
time_spreadc = 2.430358

Octave 3.2.3:
octave:1> benchmark_index (4e6, 100)
time_slice1 = 0.000502
time_slice1s = 1.084566
time_slice1v = 1.972065
time_slice2c = 0.000671
time_slice2r = 1.630831
time_slice2cv = 1.505355
time_slice2rv = 1.723218
time_slicenc = 0.000915
time_slicend = 0.541328
time_slicens = 0.498534
time_slicen2 = 0.783243
time_spreadr = 1.350102
time_spreadc = 0.911790

OS: Ubuntu 10.04 64bit

Matlab array indexing is significantly slower!? What is wrong? Any ideas?

Michal
From: Rune Allnor on
On 7 Mai, 10:50, "Michal Kvasnicka"
<michal.kvasni...(a)gmail.remove.com> wrote:
> Hi,
>
> could anybody comment this terrible result of indexing benchmark:http://artax.karlin.mff.cuni.cz/~hajej2am/ulozna/benchmark_index.m
>
> Matlab 2010a:>> benchmark_index (4e6, 100)
>
> time_slice1 = 5.734381
> time_slice1s = 3.168516
> time_slice1v = 9.452393
> time_slice2c = 2.859510
> time_slice2r = 6.575188
> time_slice2cv = 2.765570
> time_slice2rv = 7.077045
> time_slicenc = 1.101543
> time_slicend = 1.112965
> time_slicens = 0.625092
> time_slicen2 = 1.184789
> time_spreadr = 5.156006
> time_spreadc = 2.430358
>
> Octave 3.2.3:
> octave:1> benchmark_index (4e6, 100)
> time_slice1 = 0.000502
> time_slice1s = 1.084566
> time_slice1v = 1.972065
> time_slice2c = 0.000671
> time_slice2r = 1.630831
> time_slice2cv = 1.505355
> time_slice2rv = 1.723218
> time_slicenc = 0.000915
> time_slicend = 0.541328
> time_slicens = 0.498534
> time_slicen2 = 0.783243
> time_spreadr = 1.350102
> time_spreadc = 0.911790
>
> OS: Ubuntu 10.04 64bit
>
> Matlab array indexing is significantly slower!? What is wrong? Any ideas?

Matlab has always been slow. The numbers you see are probably
due to the difference between a good and a not-at-all-as-good
implementation of an intrepreted language.

Rune
From: Jan Simon on
Dear Michal!

> could anybody comment this terrible result of indexing benchmark: http://artax.karlin.mff.cuni.cz/~hajej2am/ulozna/benchmark_index.m
> ...
> Matlab array indexing is significantly slower!? What is wrong? Any ideas?

A benchmark measures the speed of a program. The benchmark you've applied to Matlab and Octave shows, that Octave is faster for your benchmark. Why do you think that this result is "terrible"?
Your benchmark is scientifically correct or not - but "terrible" or "wrong"?!

To give more proper measurements, I'd add a "clear('b');" after each creation of a vector in the loop. Otherwise Matlab's JIT accelerator can influence the results drastically.

My idea is that only your exepctations are "wrong".

Kind regards, Jan