#11046: Some comments in the code of SparseGraph
----------------------------+-----------------------------------------------
   Reporter:  ncohen        |       Owner:  jason, ncohen, rlm
       Type:  enhancement   |      Status:  needs_review      
   Priority:  trivial       |   Milestone:  sage-4.7          
  Component:  graph theory  |    Keywords:                    
     Author:                |    Upstream:  N/A               
   Reviewer:                |      Merged:                    
Work_issues:                |  
----------------------------+-----------------------------------------------
Changes (by ncohen):

 * cc: rlm (added)
  * status:  new => needs_review


Old description:

> I was reading this code to understand a bit better how the SparseGraph
> backend worked (as it is the default one in Sage), and added comments
> while I was at it.
> I also replaced some loops initializing values by a memset, as it is
> usually faster. This produces next-to-zero improvement in Sage, but
> well.. `:-)`
>
> Before :
> {{{
> 625 loops, best of 3: 1.26 ms per loop
> sage: %timeit Graph(10000)
> 625 loops, best of 3: 1.25 ms per loop
> sage: %timeit Graph(10000)
> 625 loops, best of 3: 1.47 ms per loop
> sage: %timeit Graph(10000)
> 625 loops, best of 3: 1.25 ms per loop
> sage: %timeit Graph(10000)
> 625 loops, best of 3: 1.25 ms per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 94.7 µs per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 98.8 µs per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 95.8 µs per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 95.2 µs per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 96.6 µs per loop
> sage: %timeit Graph(100)
> 625 loops, best of 3: 95.2 µs per loop
> }}}

New description:

 I was reading this code to understand a bit better how the SparseGraph
 backend worked (as it is the default one in Sage), and added comments
 while I was at it.
 I also replaced some loops initializing values by a memset, as it is
 usually faster. This produces next-to-zero improvement in Sage, but well..
 `:-)`

 Before :
 {{{
 625 loops, best of 3: 1.26 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.25 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.47 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.25 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.25 ms per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 94.7 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 98.8 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 95.8 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 95.2 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 96.6 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 95.2 µs per loop
 }}}

 After
 {{{
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.15 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.15 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.15 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.21 ms per loop
 sage: %timeit Graph(10000)
 625 loops, best of 3: 1.15 ms per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 94.5 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 92.7 µs per loop
 sage: %timeit Graph(100)
 625 loops, best of 3: 93.5 µs per loop
 }}}

 By the way Robert, this is all mostly about touching your code and adding
 comments, and as I am trespassing I expect you may not like some of those
 `:-)`

 Nathann

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11046#comment:1>
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 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-trac?hl=en.

Reply via email to