Ticket #1276: trac_1276.patch

File trac_1276.patch, 2.2 KB (added by gfurnish, 15 years ago)

rebased & fixed devel repo patch for this.

  • new file sage/misc/compare_timings.py

    # HG changeset patch
    # User Gary Furnish <gfurnish@gfurnish.net>
    # Date 1211668811 21600
    # Node ID 314d2dca675126e1fb624547d873e5e0c1cb5563
    # Parent  32c971b0bae179860a8e249ebd0b14092008b08d
    trac 1276
    
    diff -r 32c971b0bae1 -r 314d2dca6751 sage/misc/compare_timings.py
    - +  
     1import sys
     2from sage.misc.db import load
     3
     4if len(sys.argv) < 3:
     5    print "Usage: compare_timings.py t1.sobj t2.sobj"
     6    sys.exit(1)
     7
     8try:
     9    timings1 = load(sys.argv[1])
     10    timings2 = load(sys.argv[2])
     11except AssertionError:
     12    sys.exit(2)
     13
     14
     15# fast enough?
     16hashes = [ x for x in timings1.keys() if x in timings2.keys()]
     17
     18
     19for h in hashes:
     20    t1 = timings1[h]
     21    t2 = timings2[h]
     22    print h, t1.filename, "lines", t1.linenum, "and", t2.linenum, ":"
     23    wall1 = t1.wallt
     24    wall2 = t2.wallt
     25    if wall1 < 0.00001:
     26        if wall2 >= 0.00001:
     27            print "+infty%% (%s)" % wall2
     28    else:
     29        p = (wall2-wall1)/wall1
     30        print p
     31
  • new file sage/misc/show_timings.py

    diff -r 32c971b0bae1 -r 314d2dca6751 sage/misc/show_timings.py
    - +  
     1import sys
     2from sage.misc.db import load
     3
     4if len(sys.argv) < 2:
     5    print "Usage: show_timings.py t.sobj"
     6    sys.exit(1)
     7
     8try:
     9    timings = load(sys.argv[1])
     10except AssertionError:
     11    sys.exit(2)
     12
     13for x in timings.keys():
     14    timings[x].show()
     15
  • new file sage/misc/timing.py

    diff -r 32c971b0bae1 -r 314d2dca6751 sage/misc/timing.py
    - +  
     1class DocTestTiming:
     2    "Store timings for a docstring example"
     3    def __init__(self, filename, linenum, examplename, hash, cput, wallt):
     4        self.filename = filename
     5        self.linenum = linenum
     6        self.examplename = examplename
     7        self.hash = hash
     8        self.cput = cput
     9        self.wallt = wallt
     10    def show(self):
     11        print "%s, %s, line %s, hash %s: cpu %s, wall %s" % ( self.examplename, self.filename, self.linenum, self.hash, self.cput, self.wallt )
     12