Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import yappi
import time
def foo():
pass
def bar():
for i in range(5000000):
foo()
yappi.start()
t0 = time.time()
bar()
print "Elapsed1 %f secs." % (time.time()-t0)
yappi.print_stats()
t0 = time.time()
import cProfile
cProfile.run('bar()')
print "Elapsed1 %f secs." % (time.time()-t0)
def signal_handler(signal_n, frame):
print('You pressed Ctrl+C!')
yappi.stop()
yappi.print_stats(open("yappi.out", "w"))
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
def signal_handler(signal_n, frame):
print('You pressed Ctrl+C!')
yappi.stop()
yappi.print_stats(open("yappi.out", "w"))
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
r = features.outputs["Output"][:50,:50,:50,:]
requests.append(r)
for r in requests:
r.submit()
for r in requests:
r.wait()
t2 = time.time()
print "\n\n"
print "LAZYFLOW ASYNC WAIT FEATURES: %f seconds for %d iterations" % (t2-t1,mcountf)
print " %0.3fms latency" % ((t2-t1)*1e3/mcountf,)
if doProfile:
yappi.stop()
yappi.print_stats(sort_type = yappi.SORTTYPE_TTOT)
def empty_func(b):
a = 7 + b
a = "lksejhkl JSFLAJSSDFJH AKDHAJKSDH ADKJADHK AJHSKA AKJ KAJSDH AKDAJHSKAJHD KASHDAKDJH".split(" ")
t1 = time.time()
def lots_of_work():
requests = []
for i in range(mcount):
req = Request(functools.partial(empty_func, b = 11))
req.submit()
logfile = '/tmp/total-impact.log'
yappi.clear_stats()
yappi.start()
backend.main(logfile)
### Now, in another window run
# ./services/api start
# ./services/proxy start
# ./extras/functional_test.py -i 6 -n 6
# then when it is done, in python do a Cntl C to stop the backend and return to python prompt
yappi.stop()
yappi.print_stats(sort_type=yappi.SORTTYPE_TTOT, limit=30, thread_stats_on=False)
def __exit__(self,*args):
import yappi
yappi.stop()
yappi.print_stats()
yappi.clear_stats()