#7997: Use ast to replace display hook hack
-------------------------------------+--------------------------------------
   Reporter:  acleone                |       Owner:  was       
       Type:  enhancement            |      Status:  needs_work
   Priority:  major                  |   Milestone:            
  Component:  notebook               |    Keywords:            
     Author:  Alex Leone, Tim Dumol  |    Upstream:  N/A       
   Reviewer:                         |      Merged:            
Work_issues:                         |  
-------------------------------------+--------------------------------------

Comment(by timdumol):

 Hi,

 I have managed to finish the local implementation of
 WorksheetProcess_PipesImplementation (WPPI), and I have found it to be
 roughly 251.3 ms faster than WorksheetProcess_ExpectImplementation (WPEI).
 The patch, however, makes WPEI and its remote equivalent useless, due to
 an API change on the WorksheetProcess interface. This means that to finish
 this patch, a remote implementation must be made, and that both be *very*
 thoroughly tested.

 Here are the benchmark results, if anyone's interested:

 {{{
 sage: from sagenb.interfaces.pipes_interface import
 WorksheetProcess_PipesImpl as WPPI
 sage: wp = WPPI()

 # This is without the print_expressions, which is not equivalent to what
 WPEI does. Mean: 251.53 µs
 sage: timeit("""wp.execute('print 1', preparse=False,
 print_expressions=False)\nwhile wp.is_computing(): pass""")
 625 loops, best of 3: 488 µs per loop
 sage: timeit("""wp.execute('print 1', preparse=False,
 print_expressions=False)\nwhile wp.is_computing(): pass""")
 625 loops, best of 3: 451 µs per loop
 sage: timeit("""wp.execute('print 1', preparse=False,
 print_expressions=False)\nwhile wp.is_computing(): pass""")
 625 loops, best of 3: 424 µs per loop
 sage: timeit("""wp.execute('print 1', preparse=False,
 print_expressions=False)\nwhile wp.is_computing(): pass""")
 625 loops, best of 3: 481 µs per loop
 sage: timeit("""wp.execute('print 1', preparse=False,
 print_expressions=False)\nwhile wp.is_computing(): pass""")
 625 loops, best of 3: 479 µs per loop

 sage: wp.execute('from sage.all_notebook import *; import sagenb',
 preparse=False, print_expressions=False)

 # This, on the other hand, is. Mean: 680 µs
 sage: timeit("""wp.execute('1', preparse=False)\nwhile wp.is_computing():
 pass""")
 625 loops, best of 3: 664 µs per loop
 sage: timeit("""wp.execute('1', preparse=False)\nwhile wp.is_computing():
 pass""")
 625 loops, best of 3: 734 µs per loop
 sage: timeit("""wp.execute('1', preparse=False)\nwhile wp.is_computing():
 pass""")
 5 loops, best of 3: 601 µs per loop
 sage: timeit("""wp.execute('1', preparse=False)\nwhile wp.is_computing():
 pass""")
 625 loops, best of 3: 739 µs per loop
 sage: timeit("""wp.execute('1', preparse=False)\nwhile wp.is_computing():
 pass""")
 625 loops, best of 3: 664 µs per loop

 # Note, this has preparsing. This checks to see if the speedup scales. It
 does not.
 sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): pass""")
 5 loops, best of 3: 21.5 ms per loop
 sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): pass""")
 25 loops, best of 3: 19.6 ms per loop
 sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): pass""")
 25 loops, best of 3: 19.5 ms per loop
 sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): pass""")
 25 loops, best of 3: 17.7 ms per loop
 sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): pass""")
 25 loops, best of 3: 19.7 ms per loop
 }}}

 By contrast, here is the benchmark for WPEI:

 {{{
 sage: from sagenb.interfaces.expect import
 WorksheetProcess_ExpectImplementation as WPEI
 sage: wp = WPEI()

 sage: timeit("""wp.execute('1')\nwhile wp.is_computing():\n
 wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: timeit("""wp.execute('1')\nwhile wp.is_computing():\n
 wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: timeit("""wp.execute('1')\nwhile wp.is_computing():\n
 wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: timeit("""wp.execute('1')\nwhile wp.is_computing():\n
 wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: timeit("""wp.execute('1')\nwhile wp.is_computing():\n
 wp.output_status()""")
 5 loops, best of 3: 252 ms per loop

 # Transmission lag is much slower than computation time, which accounts
 for the lack of difference, I think.
 sage: sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 sage: sage: timeit("""wp.execute('[x for x in primes(1e4)]')\nwhile
 wp.is_computing(): wp.output_status()""")
 5 loops, best of 3: 252 ms per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7997#comment:8>
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