From 91a52dc72546e6680b6b82eabe9436b9c630bc5f Mon Sep 17 00:00:00 2001 From: Spencer Clark Date: Sat, 20 Jul 2024 12:09:35 -0400 Subject: [PATCH] Add encode_cf_datetime benchmark (#9262) --- asv_bench/benchmarks/coding.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 asv_bench/benchmarks/coding.py diff --git a/asv_bench/benchmarks/coding.py b/asv_bench/benchmarks/coding.py new file mode 100644 index 00000000000..c39555243c0 --- /dev/null +++ b/asv_bench/benchmarks/coding.py @@ -0,0 +1,18 @@ +import numpy as np + +import xarray as xr + +from . import parameterized + + +@parameterized(["calendar"], [("standard", "noleap")]) +class EncodeCFDatetime: + def setup(self, calendar): + self.units = "days since 2000-01-01" + self.dtype = np.dtype("int64") + self.times = xr.date_range( + "2000", freq="D", periods=10000, calendar=calendar + ).values + + def time_encode_cf_datetime(self, calendar): + xr.coding.times.encode_cf_datetime(self.times, self.units, calendar, self.dtype)