X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1f40455a7bd764c517c7f1ddb8b4b41b4a2f7ee8..46aadf6a64881e932adb4c54cb1a8c4b22e84d67:/sdk/python/tests/performance/performance_profiler.py diff --git a/sdk/python/tests/performance/performance_profiler.py b/sdk/python/tests/performance/performance_profiler.py index 57030a795b..3be00c4546 100644 --- a/sdk/python/tests/performance/performance_profiler.py +++ b/sdk/python/tests/performance/performance_profiler.py @@ -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: @@ -10,13 +14,10 @@ # # 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 +41,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