Commits

Andriy Kornatskyy committed a45ea3f

Fixed issue #1: Benchmark: ZeroDivisionError.

Comments (0)

Files changed (1)

src/wheezy/core/benchmark.py

         ...     pass
         >>> def test_2():
         ...     pass
-        >>> b = Benchmark((test_1, test_2), 1000)
+        >>> b = Benchmark((test_1, test_2), 10)
         >>> b.report() # doctest: +ELLIPSIS
-        noname: 2 x 1000
+        noname: 2 x 10
         baseline throughput change target
           100.0% ...rps  +0.0% test_1
         ...% ...rps ...% test_2
         print("%s %s %s %s" % ("baseline", "throughput", "change", "target"))
         base = None
         for (name, result) in self.run():
+            if not result:
+                print('     - %      - rps    - % ' + name)
+                continue
             if base is None:
                 base = result
             base_relative = round(base / result, 3)
 class Timer(object):
     """ Intercept a call to given method in order to compute
         timing.
-
-        >>> class A(object):
-        ...     def test(self):
-        ...         pass
-        >>> a = A()
-        >>> def test():
-        ...     a.test()
-        >>> b = Benchmark((test, ), 1000, timer=Timer(a, 'test'))
-        >>> b.report() # doctest: +ELLIPSIS
-        noname: 1 x 1000
-        baseline throughput change target
-          100.0% ...rps  +0.0% test
     """
 
     def __init__(self, target, name):