Skip to content

xarray/tests/test_cftimeindex_resample.py::test_resampler is way too slow #2874

Closed
@shoyer

Description

@shoyer

Some profiling results from pytest:

$ pytest -k cftime --durations=50
...
============================================= slowest 50 test durations ==============================================
7.92s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-right-700T]
7.45s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-None-700T]
7.17s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-right-700T]
7.12s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-None-700T]
7.12s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-right-700T]
7.03s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-None-700T]
6.88s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-None-700T]
6.70s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-right-700T]
5.88s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-right-12H]
5.69s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-None-12H]
5.55s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-None-12H]
5.44s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-right-12H]
5.44s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-None-12H]
5.32s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-right-12H]
5.21s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-right-12H]
5.08s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-None-12H]
1.56s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-right-None-700T]
1.36s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-right-right-700T]
1.22s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-None-right-700T]
1.19s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-None-None-700T]
1.16s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-None-None-700T]
1.15s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-None-right-700T]
1.11s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-right-None-700T]
1.09s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-right-right-700T]
0.96s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-None-None-12H]
0.93s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-None-right-12H]
0.93s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-right-None-12H]
0.91s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-None-None-12H]
0.91s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-31-right-right-12H]
0.89s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-right-None-12H]
0.88s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-None-right-12H]
0.86s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3Q_AUG-24-right-right-12H]
0.69s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-None-8001T]
0.69s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-right-8001T]
0.66s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-None-8001T]
0.65s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-right-8001T]
0.64s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-right-8D]
0.62s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-right-8D]
0.62s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-right-8001T]
0.60s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-None-8001T]
0.59s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-right-8D]
0.59s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-right-8001T]
0.57s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-right-8D]
0.57s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-None-8001T]
0.38s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[41987T-31-None-None-700T]
0.36s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-None-None-8D]
0.36s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-None-None-8D]
0.34s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-24-right-None-8D]
0.33s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[3AS_JUN-31-right-None-8D]
0.33s call     xarray/tests/test_cftimeindex_resample.py::test_resampler[41987T-31-right-right-700T]

This is a heavily parametrized test, and many of these test cases take 5+ seconds to run! Are there ways we could simplify these tests to make them faster?

On my laptop, this test alone roughly doubles the runtime of our entire test suite, increasing it from about 2 minutes to 4 minutes.

@jwenfai @spencerkclark Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions