I made more tests with the same operation, restricting Matlab to use a
single processing unit. I got:

- Matlab: 0.0063 sec avg
- Numpy: 0.026 sec avg
- Numpy with weave.blitz: 0.0041

Note that weave.blitz is even faster than Matlab (slightly).
I tried on an older computer, and I got similar results between matlab and
numpy without weave.blitz, so maybe it has to do with 'new' vectorization
opcodes.

Anyhow, even though these results are not very promising, it gets worse if I
try to do something like:

result = (m - 0.5)*0.3

and I get the following timings:

- Matlab: 0.0089
- Numpy: 0.051
- Numpy with blitz: 0.0043

Now blitz is considerably faster! Anyways, I am concerned about numpy being
much slower, in this case taking 2x the time of the previous operation.
I guess this is because of the way that python operands/arguments are
passed. Should I always use weave.blitz?

Carlos

On Tue, Jul 19, 2011 at 1:40 PM, Carlos Becker <carlosbec...@gmail.com>wrote:

> Hi Pauli, thanks for the quick answer.
> Is there a way to check the optimization flags of numpy after installation?
>
> I am away of a matlab installation now, but I remember I saw a single
> processor active with matlab. I will check it again soon
>
> Thanks!
>
>
>
> El 19/07/2011, a las 13:10, Pauli Virtanen <p...@iki.fi> escribió:
>
>
>  Tue, 19 Jul 2011 11:05:18 +0200, Carlos Becker wrote:
>>
>>> Hi, I started with numpy a few days ago. I was timing some array
>>> operations and found that numpy takes 3 or 4 times longer than Matlab on
>>> a simple array-minus-scalar operation.
>>> This looks as if there is a lack of vectorization, even though this is
>>> just a guess. I hope this is not reposting. I tried searching the
>>> mailing list database but did not find anything related specifically to
>>> a problem like this one.
>>>
>>
>> I see essentially no performance difference:
>>
>> Matlab [7.10.0.499 (R2010a)]: 0.0321
>> Numpy [1.6.0]: 0.03117567
>>
>> If later versions of Matlab can parallelize the computation across
>> multiple processors, that could be one possibility for the difference
>> you see. Alternatively, you may have compiled Numpy with optimizations
>> turned off.
>>
>> ______________________________**_________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/**listinfo/numpy-discussion<http://mail.scipy.org/mailman/listinfo/numpy-discussion>
>>
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to