#4761: [with patch, needs review] global cputime (inclusive some subprocesses 
like
Singular)
-------------------------+--------------------------------------------------
 Reporter:  malb         |        Owner:  malb      
     Type:  enhancement  |       Status:  new       
 Priority:  major        |    Milestone:  sage-3.2.2
Component:  misc         |   Resolution:            
 Keywords:               |  
-------------------------+--------------------------------------------------
Comment (by was):

 This needs to be rewritten since it makes the faulty assumption that there
 is at most one interface to singular/magma, etc., at a given moment, and
 also ignores many of the interfaces needlessly (?).  To emphasize the
 first point, if I do:
 {{{
 sage: s = Singular()
 sage: t = Singular()
 sage: s('2+2')
 4
 sage: t('2+2')
 4
 }}}
 then none of the computations above will be seen by cputime_global().

 Regarding the second point, here is a one liner that allows you to get a
 list of *all* interface objects:
 {{{
 sage: print [s() for s in sage.interfaces.quit.expect_objects if s()]
 [Mathematica, Singular, Axiom, Gap, Genus2reduction, GP/PARI interpreter,
 Kash, Lisp Interpreter, Magma, Macaulay2, Maple, Maxima, Matlab, Mupad,
 Mwrank, Octave, Sage, LiE Interpreter, R Interpreter, Maxima, Maxima, R
 Interpreter]
 }}}

 If you start more, they get *registered* in the
 sage.interfaces.quit.expect_objects list.

 For example, this illustrates getting all currently running interface
 objects:
 {{{
 sage: gp('2+2')
 4
 sage: s = Singular()
 sage: s('2+3')
 5
 sage: magma('5')
 5
 sage: [s() for s in sage.interfaces.quit.expect_objects if s() and
 s().is_running()]
 [GP/PARI interpreter, Magma, Singular]
 }}}

 You could do this before and after the computation, and for newly started
 interface objects, the cputime for that one would be the total cputime
 (i.e., it defaults to 0).
 You could also just get all interface objects, even ones that aren't yet
 running, but that is NOT as useful, imho, since calling cputime() on them
 starts them up (which is terrible)...

 Anyway, hopefully the above has enough "interface fu" that you can easily
 write the ultimate version of cputime.  And maybe it should just replace
 cputime?  I.e.,

 {{{
 sage: cputime()   # what you write
 sage: cputime(subprocesses=False)  # the original cputime?
 }}}

 It probably depends on how much overhead there is...   I could easily
 imagine rewriting the cputime methods for each interface so that they are
 nearly instant *unless* the interface has actually done something -- i.e.,
 put a cached value in the cputime() method for each interface that is
 cleared precisely when you send code to be evaluated.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4761#comment:2>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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