10111: Merge branch 'master' into 10111-collection-labels
[arvados.git] / sdk / python / tests / performance / performance_profiler.py
index a36ce254dd17797970121905db77d55f59f088f5..50eadd1dd9efc0e37ff5b022f02c4d528e56588e 100644 (file)
@@ -37,13 +37,9 @@ def profiled(function):
         pr = profile.Profile()
         pr.enable()
         try:
-            ret = function(*args, **kwargs)
-        except Exception as 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