#17689: A tutorial on profiling in Sage
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  ncohen                 |       Status:  needs_work
           Type:         |    Milestone:  sage-6.5
  enhancement            |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:
  documentation          |  Work issues:
       Keywords:         |       Commit:
        Authors:         |  076ebef1f7344c274e8f43f8337bc46d2a717c16
  Nathann Cohen          |     Stopgaps:
Report Upstream:  N/A    |
         Branch:         |
  public/17689           |
   Dependencies:         |
  #17616                 |
-------------------------+-------------------------------------------------
Changes (by tmonteil):

 * status:  needs_review => needs_work


Comment:

 I am a bit overloaded right now to help more on this interesting and
 important ticket, but as such, there is a big confusion between ipython
 `%timeit` and Sage `timeit`, so `%timeit` has nothing to do with `timeit
 <sage.misc.sage_timeit_class>`. A problem with `%timeit` is that it is
 ipython only, so it will not work in Sage notebook (that does not rely on
 ipython). So you need at least to point to the right documentations for
 the two different `timeit`, see `timeit?` vs `%timeit?`.

 For example, with the Sage `timeit()` command, you can not do:

 {{{
 sage: timeit(factor(1234567890))
 AttributeError: 'IntegerFactorization' object has no attribute 'lstrip'
 }}}

 You have to do

 {{{
 sage: timeit("factor(1234567890)")
 625 loops, best of 3: 72.8 µs per loop
 }}}

 But then, with ipython:

 {{{
 sage: %timeit("factor(1234567890)")
 10000000 loops, best of 3: 26.3 ns per loop
 }}}

 Which is much faster... Indeed, it measures the time for creating the
 string ! What you have to do instead is:

 {{{
 sage: %timeit(factor(1234567890))
 10000 loops, best of 3: 59.2 µs per loop
 }}}

 or

 {{{
 sage: %timeit factor(1234567890)
 10000 loops, best of 3: 59.5 µs per loop
 }}}

 So there is a confusion that can lead to a silent misuse. It think this
 distinction should be made clear.

--
Ticket URL: <http://trac.sagemath.org/ticket/17689#comment:21>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to