/usr/share/doc/python3-zope.testrunner/testrunner-profiling.txt is in python3-zope.testrunner 4.0.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | Profiling
=========
The testrunner supports hotshot and cProfile profilers. Hotshot profiler
support does not work with python2.6
>>> import os.path, sys
>>> profiler = '--profile=hotshot'
>>> if sys.hexversion >= 0x02060000:
... profiler = '--profile=cProfile'
The testrunner includes the ability to profile the test execution with hotshot
via the --profile option, if it a python <= 2.6
>>> directory_with_tests = os.path.join(this_directory, 'testrunner-ex')
>>> sys.path.append(directory_with_tests)
>>> defaults = [
... '--path', directory_with_tests,
... '--tests-pattern', '^sampletestsf?$',
... ]
>>> sys.argv = [testrunner_script, profiler]
When the tests are run, we get profiling output.
>>> from zope import testrunner
>>> testrunner.run_internal(defaults)
Running samplelayers.Layer1 tests:
...
Running samplelayers.Layer11 tests:
...
Running zope.testrunner.layer.UnitTests tests:
...
ncalls tottime percall cumtime percall filename:lineno(function)
...
Total: ... tests, 0 failures, 0 errors in ... seconds.
False
Profiling also works across layers.
>>> sys.argv = [testrunner_script, '-ssample2', profiler,
... '--tests-pattern', 'sampletests_ntd']
>>> testrunner.run_internal(defaults)
Running...
Tear down ... not supported...
ncalls tottime percall cumtime percall filename:lineno(function)...
The testrunner creates temnporary files containing hotshot profiler
data:
>>> import glob
>>> files = list(glob.glob('tests_profile.*.prof'))
>>> files.sort()
>>> files
['tests_profile.cZj2jt.prof', 'tests_profile.yHD-so.prof']
It deletes these when rerun. We'll delete these ourselves:
>>> import os
>>> for f in files:
... os.unlink(f)
|