On Thu, 30 Nov 2006 19:58:20 -0800, David Harvey
<[EMAIL PROTECTED]> wrote:
>> OK, I've done that. But honestly, I don't know what it is really
>> timing,
>> since the optimizing compiler could be doing all kinds of interesting
>> things with unrolling loops, macros, etc. And it's really pretty
>> unfair,
>> since the point is optimizing an interpreter rather than a compiler.
>> With that benchmark though, object creation is basically 12 times
>> faster
>> for Python ints, though again I think one has to be careful in
>> intepreting
>> how these things mean, when we're really trying to benchmark an
>> interpreter
>> and the object-creation-overhead of that interpreter.
>
> I agree that the interpreter setting is important. But the compiled
> setting is important too. For example, if you write a pyrex function
> that operates on matrices, whose elements are arbitrary python
> objects, and you happen to give it a matrix with python ints as
> entries, it will go something like 12 times faster than if you had
> given it a matrix with SAGE ints. Well, not 12, but still probably
> significant.
I certainly agree that the compiled setting is very very important.
I just think it is much more difficult to interpret the benchmarks,
and they are less directly relevant to the interpreted setting. More
precisely, there are two problems:
(1) make a+b fast from the interpreter
and
(2) make a+b fast from compiled code.
I think regarding (1) we're within a factor of 2-3 of what is realisitic
in the Python interpreter (because of all the other overhead), which is
pretty good,
and is a lot lot better than a factor of 7-10. Regarding (2), there is
a
potential for a lot more progress by doing further investigation, and
such work
would really be important. Perhaps in some cases we could get 8 times
faster,
since...
{{{
%sagex
from sage.rings.integer cimport Integer
def foo(n):
cdef int i
for i from 0 <= i < n:
PY_NEW(Integer)
}}}
{{{
time foo(10^6)
///
CPU time: 0.42 s, Wall time: 0.42 s
}}}
{{{
%sagex
cdef class X:
pass
def foo(n):
cdef int i
cdef mpz_t x
for i from 0 <= i < n:
PY_NEW(X)
}}}
{{{
time foo(10^6)
///
CPU time: 0.21 s, Wall time: 0.21 s
}}}
{{{
%sagex
def foo(n):
cdef int i
a = 9308234
for i from 0 <= i < n:
b = a + a
}}}
{{{
time foo(10^6)
///
CPU time: 0.05 s, Wall time: 0.05 s
}}}
-- William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---