Merge branch '8784-dir-listings'
[arvados.git] / sdk / python / tests / performance / performance_profiler.py
index a36ce254dd17797970121905db77d55f59f088f5..3be00c4546264a20c3fd55ee4cc5ece6f9000626 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
 # Use the "profiled" decorator on a test to get profiling data.
 #
 # Usage:
@@ -37,13 +41,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