Example #1
0
 def mandelbrot(self, real, imaginary):
     if CMANDELBROT:
         return cmandelbrot.mandelbrot(real, imaginary, self.iterations)
     c = complex(real, imaginary)
     z = c
     for i in xrange(self.iterations):
         if abs(z) > 2:
             return i
         z = z * z + c
     return self.iterations
 def test_c_p_time(self):
     pr = cProfile.Profile()
     pr.enable()
     t = time.time()
     cmandelbrot.mandelbrot()
     ctotal = time.time() - t
     print '\nC Mandelbrot Python Elapsed %.06f' % ctotal
     pr.disable()
     pr.print_stats()
     
     
     pr = cProfile.Profile()
     pr.enable()
     t = time.time()
     iterator.Iterator()
     ptotal = time.time() - t
     print '\nMandelbrot Python Elapsed %.06f' % ptotal
     pr.disable()
     pr.print_stats()
     print '\n %f times slower' % (ptotal / ctotal)
     
     self.assertTrue(ctotal < ptotal)