def process(args): if os.path.exists(options.output) and options.erase: shutil.rmtree(options.output) if not os.path.exists(options.output): os.makedirs(options.output) if options.static is not None: static = options.static.split(',') for dir in static: outpath = os.path.join(options.output, dir) if os.path.exists(outpath): shutil.rmtree(outpath) copytree(dir, outpath) if options.trac and os.path.isdir(options.trac): projects = read_trac(options.trac) else: if options.data: projects = read_data(options.data) else: projects = [] projects.sort(key=operator.itemgetter('desc'), cmp=locale.strcoll) timing.start() for dirpath, dirnames, filenames in os.walk(options.input): try: process_dir(dirpath, filenames, projects) except: if options.keepgoing: print 'Error!' else: raise timing.finish() print 'Website build time: %s' % timing.milli()
def main(): import DNS, timing, socket, time res = {} for server in servers: res[server] = [100000, 0, 0, 0] # min,max,tot,failed for what, querytype in lookups: for count in range(rpts): for server in servers: d = DNS.DnsRequest(server=server, timeout=1) fail = 0 timing.start() try: r = d.req(name=what, qtype=querytype) except DNS.Error: fail = 1 timing.finish() if fail: res[server][3] = res[server][3] + 1 print "(failed)", res[server][3] if 0: if r.header['ancount'] == 0: print "WARNING: Server",server,"got no answers for", \ what, querytype t = timing.milli() print server, "took", t, "ms for", what, querytype res[server][0] = min(t, res[server][0]) res[server][1] = max(t, res[server][1]) res[server][2] = res[server][2] + t for server in servers: queries = rpts * len(lookups) r = res[server] print "%-30s %2d/%2d(%3.2f%%) %dms/%dms/%dms min/avg/max" % ( socket.gethostbyaddr(server)[0], queries - r[3], queries, ((queries - r[3]) * 100.0) / queries, r[0], r[2] / queries, r[1])
def testpacker(): N = 2500 R = list(range(N)) import timing # See section 4.1.4 of RFC 1035 timing.start() for i in R: p = Packer() p.addaddr('192.168.0.1') p.addbytes('*' * 20) p.addname('f.ISI.ARPA') p.addbytes('*' * 8) p.addname('Foo.F.isi.arpa') p.addbytes('*' * 18) p.addname('arpa') p.addbytes('*' * 26) p.addname('') timing.finish() print(timing.milli(), "ms total for packing") print(round(timing.milli() / i, 4), 'ms per packing') #p.dump() u = Unpacker(p.buf) u.getaddr() u.getbytes(20) u.getname() u.getbytes(8) u.getname() u.getbytes(18) u.getname() u.getbytes(26) u.getname() timing.start() for i in R: u = Unpacker(p.buf) res = (u.getaddr(), u.getbytes(20), u.getname(), u.getbytes(8), u.getname(), u.getbytes(18), u.getname(), u.getbytes(26), u.getname()) timing.finish() print(timing.milli(), "ms total for unpacking") print(round(timing.milli() / i, 4), 'ms per unpacking')
def testpacker(): N = 2500 R = range(N) import timing # See section 4.1.4 of RFC 1035 timing.start() for i in R: p = Packer() p.addaddr('192.168.0.1') p.addbytes('*' * 20) p.addname('f.ISI.ARPA') p.addbytes('*' * 8) p.addname('Foo.F.isi.arpa') p.addbytes('*' * 18) p.addname('arpa') p.addbytes('*' * 26) p.addname('') timing.finish() print(timing.milli(), "ms total for packing") print(round(timing.milli() / i, 4), 'ms per packing') # p.dump() u = Unpacker(p.buf) u.getaddr() u.getbytes(20) u.getname() u.getbytes(8) u.getname() u.getbytes(18) u.getname() u.getbytes(26) u.getname() timing.start() for i in R: u = Unpacker(p.buf) res = (u.getaddr(), u.getbytes(20), u.getname(), u.getbytes(8), u.getname(), u.getbytes(18), u.getname(), u.getbytes(26), u.getname()) timing.finish() print(timing.milli(), "ms total for unpacking") print(round(timing.milli() / i, 4), 'ms per unpacking')
def testpacker(): N = 25 R = range(N) import timing # See section 4.1.4 of RFC 1035 timing.start() for i in R: p = Packer() p.addbytes('*' * 20) p.addname('f.ISI.ARPA') p.addbytes('*' * 8) p.addname('Foo.F.isi.arpa') p.addbytes('*' * 18) p.addname('arpa') p.addbytes('*' * 26) p.addname('') timing.finish() print round(timing.milli() * 0.001 / N, 3), 'seconds per packing' p.dump() u = Unpacker(p.buf) u.getbytes(20) u.getname() u.getbytes(8) u.getname() u.getbytes(18) u.getname() u.getbytes(26) u.getname() timing.start() for i in R: u = Unpacker(p.buf) res = (u.getbytes(20), u.getname(), u.getbytes(8), u.getname(), u.getbytes(18), u.getname(), u.getbytes(26), u.getname()) timing.finish() print round(timing.milli() * 0.001 / N, 3), 'seconds per unpacking' for item in res: print item
def _cursor_execute(cursor,sql, vars): utils.sql_log("\n%s\n" % sql) utils.sql_log("\n%s\n" % str(vars)) # TODO: maybe time things only if debug flag is on timing.start() cursor.execute(sql, vars) timing.finish() elapsed = timing.milli() if elapsed > config.TIMING_THRESHOLD: utils.sql_log("TIMING: " + str(elapsed))
def __release_flvfile(self, flags): self.file.close() if self.cmd in ["mplayer"]: timing.finish() # watchtime is in seconds wt = (timing.milli() / 1000.0) + self.entry.get_watchtime() self.entry.set_watchtime(wt) self.entry.set_count(self.entry.get_count() + 1) stats.categorize(self.entry) stats.update_stat_lists(self.entry) self.detach_subtitles()
def play_game(game, *players): "Play an n-person, move-alternating game." #timing added from timing.py timing.start() state = game.initial while True: for player in players: move = player(game, state) state = game.make_move(move, state) if game.terminal_test(state): game.display(state) timing.finish() sec = timing.seconds() thousandths = (timing.milli() % 1000) #print "\n{0}.{1} seconds\n\n".format(sec, thousandths) return game.end_game(game.utility(state, players[0]), state)
def main(): import DNS, timing, socket, time res = {} for server in servers: res[server] = [100000,0,0,0] # min,max,tot,failed for what,querytype in lookups: for count in range(rpts): for server in servers: d = DNS.DnsRequest(server=server,timeout=1) fail = 0 timing.start() try: r=d.req(name=what,qtype=querytype) except DNS.Error: fail = 1 timing.finish() if fail: res[server][3] = res[server][3] + 1 print "(failed)",res[server][3] if 0: if r.header['ancount'] == 0: print "WARNING: Server",server,"got no answers for", \ what, querytype t = timing.milli() print server,"took",t,"ms for",what,querytype res[server][0] = min(t,res[server][0]) res[server][1] = max(t,res[server][1]) res[server][2] = res[server][2] + t for server in servers: queries = rpts * len(lookups) r = res[server] print "%-30s %2d/%2d(%3.2f%%) %dms/%dms/%dms min/avg/max" % ( socket.gethostbyaddr(server)[0], queries - r[3], queries, ((queries-r[3])*100.0)/queries, r[0], r[2] / queries, r[1])
def process(args): if os.path.exists(options.output) and options.erase: shutil.rmtree(options.output) safe_makedir(options.output) if options.static is not None: static = options.static.split(','); for dir in static: outpath = os.path.join(options.output, dir) if os.path.exists(outpath): shutil.rmtree(outpath) copytree(dir, outpath) if options.input is not None: timing.start() for dirpath, dirnames, filenames in os.walk(options.input): try: process_dir(dirpath, filenames) except: if options.keepgoing: print 'Error!' else: raise timing.finish() if not options.rss: print 'Website build time: %s' % timing.milli()
from test_support import verbose import timing r = range(100000) if verbose: print 'starting...' timing.start() for i in r: pass timing.finish() if verbose: print 'finished' secs = timing.seconds() milli = timing.milli() micro = timing.micro() if verbose: print 'seconds:', secs print 'milli :', milli print 'micro :', micro
switchfunc=sddesw, mapfunc=sddemaps, tol=0.000005, dt=1.0, hbsize=1000, nlag=1, nsw=2, ssc=ddestsc) #print sdde_eg.data odetitles = ["prey", "predators"] sddetitles = [r"\large resources", r"\large consumers"] ddetitles = ["blowflies"] if timeit: timing.finish() print(str(timing.seconds())+"."+str(timing.milli())+" seconds") try: from pyx import * ''' Print the ODE model ''' odepp = graph.graphxy(width=15, height=12, x=graph.axis.linear(min=0, max=300, title=r"time $t$"), y=graph.axis.linear(min=0, max=220, title=r"population sizes"),
def measures_interface(): timing.start() POSITION = True # 30 EPOCH = True # 13 LISTCODES = True # 25 SOURCELIST = True # 39 LINELIST = True # 24 OBSLIST = True # 28 SPECTRALLINE = True # 40 FRAMENOW = True # 18 SHOWFRAME = True # 37 DIRECTION = True # 6 DIRSHOW = True # 7 COMETNAME = True # 3 COMETTYPE = True # 5 COMETTOPO = True # 4 RISE = True # 32 RISESET = True # 33 BASELINE = True # 2 EXPAND = True # 14 SEPARATION = True # 34 POSANGLE = True # 29 RADIALVELOCITY = True # 31 DOPPLER = True # 10 FREQUENCY = True # 19 SOURCE = True # 38 OBSERVATORY = True # 27 EARTHMAGNETIC = True # 12 UVW = True # 46 DONE = True # 9 TODOPPLER = True # 41 TOFREQUENCY = True # 42 TORADIALVELOCITY = True # 43 TORESTFREQUENCY = True # 44 TOUVW = True # 45 MEASURE = True # 26 GETREF = True # 21 GETOFFSET = True # 20 GETTYPE = True # 22 GETVALUE = True # 23 SHOW = True # 35 SHOWAUTO = True # 36 DOFRAME = True # 8 DOSHOWAUTO = True # 11 FRAMEAUTO = True # 15 FRAMECOMET = True # 16 FRAMENOAUTO = True # 17 ADDXVALUE = True # 0 ASBASELINE = True # 1 if (ADDXVALUE): addxvalue() if (ASBASELINE): asbaseline() if (BASELINE): baseline() if (COMETNAME): cometname() if (COMETTOPO): comettopo() if (COMETTYPE): comettype() if (DIRECTION): direction() if (DIRSHOW): dirshow() if (DOFRAME): doframe() if (DONE): done() if (DOPPLER): doppler() if (EARTHMAGNETIC): earthmagnetic() if (EPOCH): epoch() if (EXPAND): expand() if (FRAMECOMET): framecomet() if (FRAMENOW): framenow() if (FREQUENCY): frequency() if (GETOFFSET): getoffset() if (GETREF): getref() if (GETTYPE): gettype() if (GETVALUE): getvalue() if (LINELIST): linelist() if (LISTCODES): listcodes() if (MEASURE): measure() if (OBSERVATORY): observatory() if (OBSLIST): obslist() if (POSANGLE): posangle() if (POSITION): position() if (RADIALVELOCITY): radialvelocity() if (RISE): rise() if (RISESET): riseset() if (SEPARATION): separation() if (SHOW): show() if (SHOWFRAME): showframe() if (SOURCE): source() if (SOURCELIST): sourcelist() if (SPECTRALLINE): spectralline() if (TODOPPLER): todoppler() if (TOFREQUENCY): tofrequency() if (TORADIALVELOCITY): toradialvelocity() if (TORESTFREQUENCY): torestfrequency() if (TOUVW): touvw() if (UVW): uvw() timing.finish() print 'Measures interface time is: ', timing.milli() / 1000. return True
tol=0.000005, dt=1.0, hbsize=1000, nlag=1, nsw=2, ssc=ddestsc) #print sdde_eg.data odetitles = ["prey", "predators"] sddetitles = [r"\large resources", r"\large consumers"] ddetitles = ["blowflies"] if timeit: timing.finish() print(str(timing.seconds()) + "." + str(timing.milli()) + " seconds") try: from pyx import * ''' Print the ODE model ''' odepp = graph.graphxy(width=15, height=12, x=graph.axis.linear(min=0, max=300, title=r"time $t$"), y=graph.axis.linear(min=0, max=220, title=r"population sizes"), key=graph.key.key(pos="tl"))
def run(self, function): timing.start() self.solution = function() timing.finish() self.time = timing.milli()
print dir(sns_napi) #help(sns_napi) handle = sns_napi.open("/SNS/users/pf9/REF_M_50-zipped.nxs") print "opengroup(entry,NXentry)", sns_napi.opengroup(handle, "entry", "NXentry") #print "opengroup(data,NXdata)",sns_napi.opengroup(handle,"data","NXdata") print "opengroup(bank1,NXdata)", sns_napi.opengroup(handle, "bank1", "NXdata") print "getnextentry()", sns_napi.getnextentry(handle) print "getnextentry()", sns_napi.getnextentry(handle) print "opendata(x_pixel_offset)", sns_napi.opendata(handle, "x_pixel_offset") print "getattr(axis)", sns_napi.getattr(handle, "axis") print "getattr(units)", sns_napi.getattr(handle, "units") xpo = sns_napi.getdata(handle) print "getdata()", xpo.__type__, xpo, len(xpo) print "closedata()", sns_napi.closedata(handle) print "opendata(data)", sns_napi.opendata(handle, "data") (dims, type) = sns_napi.getinfo(handle) print "getinfo()", (dims, type) print "getnextattr()", sns_napi.getnextattr(handle) print "getdata benchmark [:sec.milli]" timing.start() sns_napi.getdata(handle) timing.finish() print_mark("", timing.milli()) print "getslab((0,0,0),(1,1,167))", sns_napi.getslab(handle, (0, 0, 0), (1, 1, 167)) print "getslab((1,1,0),(1,1,167))", sns_napi.getslab(handle, (1, 0, 0), (1, 1, 167))
def measures_interface(): timing.start() POSITION = True # 30 EPOCH = True # 13 LISTCODES = True # 25 SOURCELIST = True # 39 LINELIST = True # 24 OBSLIST = True # 28 SPECTRALLINE = True # 40 FRAMENOW = True # 18 SHOWFRAME = True # 37 DIRECTION = True # 6 DIRSHOW = True # 7 COMETNAME = True # 3 COMETTYPE = True # 5 COMETTOPO = True # 4 RISE = True # 32 RISESET = True # 33 BASELINE = True # 2 EXPAND = True # 14 SEPARATION = True # 34 POSANGLE = True # 29 RADIALVELOCITY = True # 31 DOPPLER = True # 10 FREQUENCY = True # 19 SOURCE = True # 38 OBSERVATORY = True # 27 EARTHMAGNETIC = True # 12 UVW = True # 46 DONE = True # 9 TODOPPLER = True # 41 TOFREQUENCY = True # 42 TORADIALVELOCITY = True # 43 TORESTFREQUENCY = True # 44 TOUVW = True # 45 MEASURE = True # 26 GETREF = True # 21 GETOFFSET = True # 20 GETTYPE = True # 22 GETVALUE = True # 23 SHOW = True # 35 SHOWAUTO = True # 36 DOFRAME = True # 8 DOSHOWAUTO = True # 11 FRAMEAUTO = True # 15 FRAMECOMET = True # 16 FRAMENOAUTO = True # 17 ADDXVALUE = True # 0 ASBASELINE = True # 1 if (ADDXVALUE): addxvalue() if (ASBASELINE): asbaseline() if (BASELINE): baseline() if (COMETNAME): cometname() if (COMETTOPO): comettopo() if (COMETTYPE): comettype() if (DIRECTION): direction() if (DIRSHOW): dirshow() if (DOFRAME): doframe() if (DONE): done() if (DOPPLER): doppler() if (EARTHMAGNETIC): earthmagnetic() if (EPOCH): epoch() if (EXPAND): expand() if (FRAMECOMET): framecomet() if (FRAMENOW): framenow() if (FREQUENCY): frequency() if (GETOFFSET): getoffset() if (GETREF): getref() if (GETTYPE): gettype() if (GETVALUE): getvalue() if (LINELIST): linelist() if (LISTCODES): listcodes() if (MEASURE): measure() if (OBSERVATORY): observatory() if (OBSLIST): obslist() if (POSANGLE): posangle() if (POSITION): position() if (RADIALVELOCITY): radialvelocity() if (RISE): rise() if (RISESET): riseset() if (SEPARATION): separation() if (SHOW): show() if (SHOWFRAME): showframe() if (SOURCE): source() if (SOURCELIST): sourcelist() if (SPECTRALLINE): spectralline() if (TODOPPLER): todoppler() if (TOFREQUENCY): tofrequency() if (TORADIALVELOCITY): toradialvelocity() if (TORESTFREQUENCY): torestfrequency() if (TOUVW): touvw() if (UVW): uvw() timing.finish() print 'Measures interface time is: ',timing.milli()/1000. return True
nessi_data=nessi_list.NessiList() nessi_data.__array__.__set_from_NessiVector__(nessi_data.__array__,data) return nessi_data print dir(sns_napi) #help(sns_napi) handle=sns_napi.open("/SNS/users/pf9/REF_M_50-zipped.nxs") print "opengroup(entry,NXentry)",sns_napi.opengroup(handle,"entry","NXentry") #print "opengroup(data,NXdata)",sns_napi.opengroup(handle,"data","NXdata") print "opengroup(bank1,NXdata)",sns_napi.opengroup(handle,"bank1","NXdata") print "getnextentry()",sns_napi.getnextentry(handle) print "getnextentry()",sns_napi.getnextentry(handle) print "opendata(x_pixel_offset)",sns_napi.opendata(handle,"x_pixel_offset") print "getattr(axis)",sns_napi.getattr(handle,"axis") print "getattr(units)",sns_napi.getattr(handle,"units") xpo=sns_napi.getdata(handle) print "getdata()",xpo.__type__,xpo,len(xpo) print "closedata()",sns_napi.closedata(handle) print "opendata(data)",sns_napi.opendata(handle,"data") (dims,type)=sns_napi.getinfo(handle) print "getinfo()",(dims,type) print "getnextattr()",sns_napi.getnextattr(handle) print "getdata benchmark [:sec.milli]" timing.start() sns_napi.getdata(handle) timing.finish() print_mark("",timing.milli()) print "getslab((0,0,0),(1,1,167))",sns_napi.getslab(handle,(0,0,0),(1,1,167)) print "getslab((1,1,0),(1,1,167))",sns_napi.getslab(handle,(1,0,0),(1,1,167))
import timing import time def procedure(): time.sleep(1.234) timing.start() procedure() timing.finish() print "seconds:", timing.seconds() print "milliseconds:", timing.milli() print "microseconds:", timing.micro() ## seconds: 1 ## milliseconds: 1239 ## microseconds: 1239999
import timing import time def procedure(): time.sleep(1.234) timing.start() procedure() timing.finish() print("seconds:", timing.seconds()) print("milliseconds:", timing.milli()) print("microseconds:", timing.micro()) ## seconds: 1 ## milliseconds: 1239 ## microseconds: 1239999