Skip to content

Commit

Permalink
🕵️ benchmark NaN downsamplers
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdd committed Jan 24, 2024
1 parent 910c788 commit 62b0489
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions tests/benchmarks/test_downsamplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
M4Downsampler,
MinMaxDownsampler,
MinMaxLTTBDownsampler,
NaNM4Downsampler,
NaNMinMaxDownsampler,
NaNMinMaxLTTBDownsampler,
)

NB_SAMPLES = ["100,000", "1,000,000"]
Expand Down Expand Up @@ -52,6 +55,39 @@ def test_minmax_with_x(benchmark, n_samples, n_out, dtype, parallel):
benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanminmax")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanminmax_no_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the MinMaxDownsampler."""
downsampler = NaNMinMaxDownsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanminmax")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanminmax_with_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the MinMaxDownsampler."""
downsampler = NaNMinMaxDownsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

x = np.arange(n_samples)
y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


# --------------------------------------------------------------------------- #
# M4Downsampler
# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -90,6 +126,39 @@ def test_m4_with_x(benchmark, n_samples, n_out, dtype, parallel):
benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanm4")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanm4_no_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the M4Downsampler."""
downsampler = NaNM4Downsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanm4")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanm4_with_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the M4Downsampler."""
downsampler = NaNM4Downsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

x = np.arange(n_samples)
y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


# --------------------------------------------------------------------------- #
# LTTBDownsampler
# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -166,6 +235,39 @@ def test_minmaxlttb_with_x(benchmark, n_samples, n_out, dtype, parallel):
benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanminmaxlttb")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanminmaxlttb_no_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the MinMaxLTTBDownsampler."""
downsampler = NaNMinMaxLTTBDownsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, y, n_out=n_out, parallel=parallel)


@pytest.mark.benchmark(group="nanminmaxlttb")
@pytest.mark.parametrize("n_samples", NB_SAMPLES)
@pytest.mark.parametrize("n_out", N_OUT)
@pytest.mark.parametrize("dtype", Y_DTYPES)
@pytest.mark.parametrize("parallel", [False, True])
def test_nanminmaxlttb_with_x(benchmark, n_samples, n_out, dtype, parallel):
"""Test the MinMaxLTTBDownsampler."""
downsampler = NaNMinMaxLTTBDownsampler()
n_samples = int(n_samples.replace(",", ""))
n_out = int(n_out.replace(",", ""))

x = np.arange(n_samples)
y = np.random.randn(n_samples).astype(dtype)

benchmark(downsampler.downsample, x, y, n_out=n_out, parallel=parallel)


# --------------------------------------------------------------------------- #
# EveryNthDownsampler
# --------------------------------------------------------------------------- #
Expand Down

0 comments on commit 62b0489

Please sign in to comment.