2 """See how slow failure creation is"""
5 from twisted.python import failure
8 O = [0, 20, 40, 60, 80, 10, 30, 50, 70, 90]
12 return random.choice([None, 1, 'Hello', [], {1: 1}, (1, 2, 3)])
15 return ';'.join(['x%d = %s' % (i, pickVal()) for i in range(n)])
18 for i in range(DEPTH):
20 def deepFailure%d_%d():
23 """ % (nLocals, i, makeLocals(nLocals), nLocals, i + 1)
27 def deepFailure%d_%d():
29 """ % (nLocals, DEPTH)
35 eval('deepFailure%d_0' % n)()
42 eval('deepFailure%d_0' % n)()
44 str(failure.Failure())
46 class PythonException(Exception): pass
51 failure.Failure(PythonException())
55 from timer import timeit
60 # print 'easy failing', i, timeit(fail_easy, 1, i)
63 print 'failing', i, timeit(fail, 1, i)
66 # print 'string failing', i, timeit(fail_str, 1, i)