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