Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List 25 slowest tests #5969

Merged
merged 1 commit into from
May 22, 2024
Merged

Conversation

bouweandela
Copy link
Member

@bouweandela bouweandela commented May 22, 2024

🚀 Pull Request

Description

Running the iris test suite feels a bit slow when developing. This pull request adds a pytest option that causes the 25 slowest tests to be displayed with every test run. This will make test run times more visible to developers and in that way encourage writing faster tests.

Examples

In CI: https://github.com/SciTools/iris/actions/runs/9186913624/job/25263500853?pr=5969#step:12:1646

Locally:

$ pytest lib/iris/tests/unit/cube/test_Cube.py
============================================================================ test session starts ============================================================================
platform linux -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/bandela/src/scitools/iris
configfile: pyproject.toml
plugins: cov-5.0.0, xdist-3.5.0
collected 354 items                                                                                                                                                         

lib/iris/tests/unit/cube/test_Cube.py ............................................................................................................................... [ 35%]
..................................................................................................................................................................... [ 82%]
..............................................................                                                                                                        [100%]

============================================================================= warnings summary ==============================================================================
lib/iris/tests/unit/cube/test_Cube.py::Test___init___data::test_matrix
  /home/bandela/src/scitools/iris/lib/iris/tests/unit/cube/test_Cube.py:68: PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
    data = np.matrix([[1, 2, 3], [4, 5, 6]])

lib/iris/tests/unit/cube/test_Cube.py: 41 warnings
  /home/bandela/src/scitools/iris/lib/iris/coords.py:2153: IrisVagueMetadataWarning: Cannot check if coordinate is contiguous: Invalid operation for 'y', with 0 bound(s). Contiguous bounds are only defined for 1D coordinates with 2 bounds. Metadata may not be fully descriptive for 'y'. Ignoring bounds.
    warnings.warn(

lib/iris/tests/unit/cube/test_Cube.py: 22 warnings
  /home/bandela/src/scitools/iris/lib/iris/coords.py:2153: IrisVagueMetadataWarning: Cannot check if coordinate is contiguous: Invalid operation for 'x', with 0 bound(s). Contiguous bounds are only defined for 1D coordinates with 2 bounds. Metadata may not be fully descriptive for 'x'. Ignoring bounds.
    warnings.warn(

lib/iris/tests/unit/cube/test_Cube.py: 26 warnings
  /home/bandela/src/scitools/iris/lib/iris/coords.py:2140: IrisVagueMetadataWarning: Collapsing a multi-dimensional coordinate. Metadata may not be fully descriptive for 'full_x'.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================== slowest 25 durations ============================================================================
2.26s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_dimension_given
2.25s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_coord_name_given
2.22s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_coord_given
2.21s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_duplicate_coordinate_given
2.21s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_non_orthogonal_coordinates_given
0.91s call     lib/iris/tests/unit/cube/test_Cube.py::Test_convert_units::test_unit_multiply
0.20s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_multidim_slice_coord_given
0.15s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_coord_given
0.15s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_reversed_dimension_given
0.15s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_coord_name_given
0.15s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_dimension_given
0.08s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_nodimension
0.06s call     lib/iris/tests/unit/cube/test_Cube.py::Test_xml::test_ancils
0.02s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_dim_order::test_all_permutations
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test__init__mesh::test_meshcoords_equal_meshes
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_nonexistent_dimension_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test__init__mesh::test_fail_meshcoords_different_meshes
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_nonexistent_coord_name_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_nonexistent_coord_name_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_nonexistent_dimension_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_1d_slice_nonexistent_coord_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_intersection__Metadata::test_metadata_wrapped
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_slices_over::test_2d_slice_nonexistent_coord_given
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test__add_aux_coord__mesh::test_fail_different_dimension
0.01s call     lib/iris/tests/unit/cube/test_Cube.py::Test_collapsed__multidim_weighted_with_dim_metadata::test_weighted_fullweights_lazy_x
===================================================================== 354 passed, 90 warnings in 14.03s =====================================================================

Consult Iris pull request check list


Add any of the below labels to trigger actions on this PR:

  • benchmark_this Request that this pull request be benchmarked to check if it introduces performance shifts

Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.78%. Comparing base (3e1e80e) to head (5bb2ce4).
Report is 1 commits behind head on main.

Current head 5bb2ce4 differs from pull request most recent head 30d6c11

Please upload reports for the commit 30d6c11 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5969      +/-   ##
==========================================
- Coverage   89.78%   89.78%   -0.01%     
==========================================
  Files          93       93              
  Lines       23010    23007       -3     
  Branches     5018     5017       -1     
==========================================
- Hits        20660    20657       -3     
  Misses       1620     1620              
  Partials      730      730              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bouweandela bouweandela marked this pull request as ready for review May 22, 2024 07:25
@bjlittle bjlittle self-requested a review May 22, 2024 13:33
Copy link
Member

@bjlittle bjlittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bouweandela Yup, this is really handy, thanks for adding this useful testing diagnostic 🍻

@bjlittle bjlittle merged commit 46d2cf6 into SciTools:main May 22, 2024
20 checks passed
@bouweandela bouweandela deleted the list-test-durations branch May 22, 2024 13:45
stephenworsley added a commit to stephenworsley/iris that referenced this pull request Jun 10, 2024
* main: (759 commits)
  Bump scitools/workflows from 2024.05.1 to 2024.06.0 (SciTools#5986)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5980)
  Updated environment lockfiles (SciTools#5983)
  Bump scitools/workflows from 2024.05.0 to 2024.05.1 (SciTools#5984)
  Make `slices_over` tests go faster (SciTools#5973)
  Updated environment lockfiles (SciTools#5979)
  Update lock files with associated fixes (SciTools#5953)
  List 25 slowest tests (SciTools#5969)
  used a note to highlight some text (SciTools#5971)
  Lazy `iris.cube.Cube.rolling_window` (SciTools#5795)
  Add memory benchmarks (SciTools#5960)
  Whatsnew for several benchmark developments. (SciTools#5961)
  Remove "on-demand" from some benchmarks (SciTools#5959)
  Add bm_runner 'trialrun' subcommand. (SciTools#5957)
  Automatically install iris-test-data for benchmark data generation (SciTools#5958)
  Added benchmarks for collapse and aggregate (SciTools#5954)
  Use tracemalloc for memory measurements. (SciTools#5948)
  Provide a Nox `benchmarks` session as the recommended entry point (SciTools#5951)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5952)
  Remove unit benchmarks (SciTools#5949)
  ...
tkknight added a commit to tkknight/iris that referenced this pull request Jun 20, 2024
* upstream/main: (42 commits)
  Mesh saveload fix (SciTools#6004)
  used tabs for the install info (SciTools#6013)
  Fix array_equal behaviour for masked arrays (SciTools#4457)
  Bump scitools/workflows from 2024.06.1 to 2024.06.2 (SciTools#6008)
  [pre-commit.ci] pre-commit autoupdate (SciTools#6007)
  Updated environment lockfiles (SciTools#5996)
  Added more descriptive errors within concatenate (SciTools#6005)
  Bump scitools/workflows from 2024.06.0 to 2024.06.1 (SciTools#5998)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5997)
  Bump scitools/workflows from 2024.05.1 to 2024.06.0 (SciTools#5986)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5980)
  Updated environment lockfiles (SciTools#5983)
  Bump scitools/workflows from 2024.05.0 to 2024.05.1 (SciTools#5984)
  Make `slices_over` tests go faster (SciTools#5973)
  Updated environment lockfiles (SciTools#5979)
  Update lock files with associated fixes (SciTools#5953)
  List 25 slowest tests (SciTools#5969)
  used a note to highlight some text (SciTools#5971)
  Lazy `iris.cube.Cube.rolling_window` (SciTools#5795)
  Add memory benchmarks (SciTools#5960)
  ...
tkknight added a commit to tkknight/iris that referenced this pull request Jun 23, 2024
* upstream/main: (143 commits)
  Updated environment lockfiles (SciTools#6020)
  Add `MeshCoord.collapsed` (SciTools#6003)
  Bump scitools/workflows from 2024.06.2 to 2024.06.3 (SciTools#6015)
  Mesh saveload fix (SciTools#6004)
  used tabs for the install info (SciTools#6013)
  Fix array_equal behaviour for masked arrays (SciTools#4457)
  Bump scitools/workflows from 2024.06.1 to 2024.06.2 (SciTools#6008)
  [pre-commit.ci] pre-commit autoupdate (SciTools#6007)
  Updated environment lockfiles (SciTools#5996)
  Added more descriptive errors within concatenate (SciTools#6005)
  Bump scitools/workflows from 2024.06.0 to 2024.06.1 (SciTools#5998)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5997)
  Bump scitools/workflows from 2024.05.1 to 2024.06.0 (SciTools#5986)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5980)
  Updated environment lockfiles (SciTools#5983)
  Bump scitools/workflows from 2024.05.0 to 2024.05.1 (SciTools#5984)
  Make `slices_over` tests go faster (SciTools#5973)
  Updated environment lockfiles (SciTools#5979)
  Update lock files with associated fixes (SciTools#5953)
  List 25 slowest tests (SciTools#5969)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants