test/py: Add a report show test durations
PATCH v3 1/1 test/py: Add a report show test durations
Execution time varies widely with the existing tests. Provides a way to produce a summary of the time taken for each test, along with a histogram.
This is enabled with the --timing flag.
Enable it for sandbox in CI.
Example:
Duration : Number of tests
======== : ========================================
<1ms : 1
<8ms : 1
<20ms : # 20
<30ms : ######## 127
<50ms : ######################################## 582
<75ms : ####### 102
<100ms : ## 39
<200ms : ##### 86
<300ms : # 29
<500ms : ## 42
<750ms : # 16
<1.0s : # 15
<2.0s : # 23
<3.0s : 13
<5.0s : 9
<7.5s : 1
<10.0s : 6
<20.0s : 12---
Changes in v3:
- Name the var TEST_PY_EXTRA so we can use it to pass any args to test.py
Changes in v2:
- Only show the report if the --timing flag is provided
- Use --timing flag to show the report in CI for just the sandbox tests
.azure-pipelines.yml | 3 +- .gitlab-ci.yml | 3 +- doc/develop/py_testing.rst | 33 +++++++++++++++ test/py/conftest.py | 87 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 2 deletions(-)
.azure-pipelines.yml +2 -1
@@ -295,7 +295,7 @@ stages: export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:\${PATH} export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci # "\${var:+"-k \$var"}" expands to "" if \$var is empty, "-k \$var" if not - ./test/py/test.py -ra -o cache_dir="\$UBOOT_TRAVIS_BUILD_DIR"/.pytest_cache --bd \${TEST_PY_BD} \${TEST_PY_ID} \${TEST_PY_TEST_SPEC:+"-k \${TEST_PY_TEST_SPEC}"} --build-dir "\$UBOOT_TRAVIS_BUILD_DIR" --report-dir "\$UBOOT_TRAVIS_BUILD_DIR" --junitxml=\$(System.DefaultWorkingDirectory)/results.xml + ./test/py/test.py -ra -o cache_dir="\$UBOOT_TRAVIS_BUILD_DIR"/.pytest_cache --bd \${TEST_PY_BD} \${TEST_PY_ID} \${TEST_PY_EXTRA} \${TEST_PY_TEST_SPEC:+"-k \${TEST_PY_TEST_SPEC}"} --build-dir "\$UBOOT_TRAVIS_BUILD_DIR" --report-dir "\$UBOOT_TRAVIS_BUILD_DIR" --junitxml=\$(System.DefaultWorkingDirectory)/results.xml # the below corresponds to .gitlab-ci.yml "after_script" rm -rf /tmp/uboot-test-hooks /tmp/venv EOF
@@ -318,6 +318,7 @@ stages: matrix: sandbox: TEST_PY_BD: "sandbox" + TEST_PY_EXTRA: "--timing" sandbox_asan: TEST_PY_BD: "sandbox" OVERRIDE: "-a ASAN"
.gitlab-ci.yml +2 -1
@@ -89,7 +89,7 @@ stages: # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not - export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH}; export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci; - ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID} + ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID} ${TEST_PY_EXTRA} ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"} --build-dir "$UBOOT_TRAVIS_BUILD_DIR" --junitxml=/tmp/${TEST_PY_BD}/results.xml
@@ -273,6 +273,7 @@ Check packing of Python tools: sandbox test.py: variables: TEST_PY_BD: "sandbox" + TEST_PY_EXTRA: "--timing" <<: *buildman_and_testpy_dfn sandbox with clang test.py:
doc/develop/py_testing.rst +33 -0
@@ -246,6 +246,39 @@ Command-line options sets the directory used to store persistent test data. This is test data that may be re-used across test runs, such as file-system images. +--timing + shows a histogram of test duration, at the end of the run. The columns are: + + Duration + the duration-bucket that this test was in + + Total + total time of all tests in this bucket + + Number of tests + graph showing the number of tests in this bucket, with the actual number + shown at the end + + Example:: + + Duration : Total | Number of tests + ======== : ======= |======================================== + <20ms : 418ms |## 23 + <30ms : 9.1s |######################################## 347 + <40ms : 10.0s |################################# 294 + <50ms : 3.1s |####### 69 + <75ms : 2.6s |#### 43 + <100ms : 1.7s |## 19 + <200ms : 3.0s |## 22 + <300ms : 1.7s | 7 + <400ms : 675ms | 2 + <500ms : 2.2s | 5 + <750ms : 8.3s |# 13 + <1.0s : 1.6s | 2 + <2.0s : 9.4s | 7 + <3.0s : 2.4s | 1 + <7.5s : 6.1s | 1 + `pytest` also implements a number of its own command-line options. Commonly used options are mentioned below. Please see `pytest` documentation for complete details. Execute `py.test --version` for a brief summary. Note that U-Boot's
test/py/conftest.py +87 -0
142 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 31 lines · Simon Glass
Execution time varies widely with the existing tests. Provides a way to produce a summary of the time taken for each test, along with a histogram.
This is enabled with the --timing flag.
Enable it for sandbox in CI.
Example:
Duration : Number of tests ======== : ======================================== <1ms : 1 <8ms : 1 <20ms : # 20 <30ms : ######## 127 <50ms : ######################################## 582 <75ms : ####### 102 <100ms : ## 39 <200ms : ##### 86 <300ms : # 29 <500ms : ## 42 <750ms : # 16 <1.0s : # 15 <2.0s : # 23 <3.0s : 13 <5.0s : 9 <7.5s : 1 <10.0s : 6 <20.0s : 12
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
Quoted 9 lines · Simon Glass
Execution time varies widely with the existing tests. Provides a way to produce a summary of the time taken for each test, along with a histogram.
This is enabled with the --timing flag.
Enable it for sandbox in CI.
[...]
Applied to u-boot/master, thanks!
Signature · 1 line
Tom