11308: Fix useless assertion.
[arvados.git] / sdk / python / tests / performance / performance_profiler.py
index 57030a795b1dc62c9ed851927d858e9970ac1456..50eadd1dd9efc0e37ff5b022f02c4d528e56588e 100644 (file)
 #
 #   See "test_a_sample.py" for a working example.
 #
-# To run performance tests:
-#     cd arvados/sdk/python
+# Performance tests run as part of regular test suite.
+# You can also run only the performance tests using one of the following:
 #     python -m unittest discover tests.performance
-#
-#     Alternatively, using run-tests.sh
-#         ./run-tests.sh WORKSPACE=~/arvados --only sdk/python sdk/python_test="--test-suite=tests.performance"
-#
+#     ./run-tests.sh WORKSPACE=~/arvados --only sdk/python sdk/python_test="--test-suite=tests.performance"
 
 import functools
 import os
@@ -40,13 +37,9 @@ def profiled(function):
         pr = profile.Profile()
         pr.enable()
         try:
-            ret = function(*args, **kwargs)
-        except e:
-            caught = e
-        pr.disable()
-        ps = pstats.Stats(pr, stream=outfile)
-        ps.print_stats()
-        if caught:
-            raise caught
-        return ret
+            return function(*args, **kwargs)
+        finally:
+            pr.disable()
+            ps = pstats.Stats(pr, stream=outfile)
+            ps.sort_stats('time').print_stats()
     return profiled_function