Home | History | Annotate | Download | only in pybench
      1 from pybench import Test
      2 
      3 # Check for new-style class support:

      4 try:
      5     class c(object):
      6         pass
      7 except NameError:
      8     raise ImportError
      9 
     10 ###

     11 
     12 class CreateNewInstances(Test):
     13 
     14     version = 2.0
     15     operations = 3 + 7 + 4
     16     rounds = 60000
     17 
     18     def test(self):
     19 
     20         class c(object):
     21             pass
     22 
     23         class d(object):
     24             def __init__(self,a,b,c):
     25                 self.a = a
     26                 self.b = b
     27                 self.c = c
     28 
     29         class e(object):
     30             def __init__(self,a,b,c=4):
     31                 self.a = a
     32                 self.b = b
     33                 self.c = c
     34                 self.d = a
     35                 self.e = b
     36                 self.f = c
     37 
     38         for i in xrange(self.rounds):
     39             o = c()
     40             o1 = c()
     41             o2 = c()
     42             p = d(i,i,3)
     43             p1 = d(i,i,3)
     44             p2 = d(i,3,3)
     45             p3 = d(3,i,3)
     46             p4 = d(i,i,i)
     47             p5 = d(3,i,3)
     48             p6 = d(i,i,i)
     49             q = e(i,i,3)
     50             q1 = e(i,i,3)
     51             q2 = e(i,i,3)
     52             q3 = e(i,i)
     53 
     54     def calibrate(self):
     55 
     56         class c(object):
     57             pass
     58 
     59         class d(object):
     60             def __init__(self,a,b,c):
     61                 self.a = a
     62                 self.b = b
     63                 self.c = c
     64 
     65         class e(object):
     66             def __init__(self,a,b,c=4):
     67                 self.a = a
     68                 self.b = b
     69                 self.c = c
     70                 self.d = a
     71                 self.e = b
     72                 self.f = c
     73 
     74         for i in xrange(self.rounds):
     75             pass
     76