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

[skip-ci] Add cftime groupby, resample benchmarks #7795

Merged
merged 11 commits into from
May 2, 2023
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
set -x
# ID this runner
asv machine --yes
export TMPDIR=$RUNNER_TEMP
echo "Baseline: ${{ github.event.pull_request.base.sha }} (${{ github.event.pull_request.base.label }})"
echo "Contender: ${GITHUB_SHA} (${{ github.event.pull_request.head.label }})"
# Use mamba for env creation
Expand Down
1 change: 1 addition & 0 deletions asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// determined by looking for tools on the PATH environment
// variable.
"environment_type": "conda",
"conda_channels": ["conda-forge"],

// timeout in seconds for installing any dependencies in environment
// defaults to 10 min
Expand Down
31 changes: 31 additions & 0 deletions asv_bench/benchmarks/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,34 @@ def setup(self, *args, **kwargs):
super().setup(**kwargs)
self.ds1d = self.ds1d.chunk({"time": 50})
self.ds2d = self.ds2d.chunk({"time": 50, "z": 4})


class ResampleCFTime:
def setup(self, *args, **kwargs):
self.ds1d = xr.Dataset(
{
"b": ("time", np.arange(365.0 * 24)),
},
coords={
"time": xr.date_range(
"2001-01-01", freq="H", periods=365 * 24, calendar="noleap"
)
},
)
self.ds2d = self.ds1d.expand_dims(z=10)
self.ds1d_mean = self.ds1d.resample(time="48H").mean()
self.ds2d_mean = self.ds2d.resample(time="48H").mean()


class GroupByCFTime:
def setup(self, *args, **kwargs):
arr = np.random.randn(10, 10, 365 * 30)
time = xr.date_range("2000", periods=30 * 365, calendar="noleap")
self.da = xr.DataArray(arr, dims=("y", "x", "time"), coords={"time": time})
self.gb = self.da.groupby("time.year")

def time_init(self, ndim):
self.da.groupby("time.year")

def time_mean(self):
self.gb.mean()