Skip to content

Commit eb66bcc

Browse files
committed
Merge pull request #11450 from kawochen/CLN-PERF-roll-median
CLN/PERF: remove used functions; use C skip list for rolling median
2 parents ce726f5 + 11c8427 commit eb66bcc

File tree

7 files changed

+522
-421
lines changed

7 files changed

+522
-421
lines changed

asv_bench/benchmarks/gil.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,73 @@ def time_period_to_datetime(self):
366366
def run(period):
367367
period.to_timestamp()
368368
run(self.period)
369+
370+
371+
class nogil_rolling_algos_slow(object):
372+
goal_time = 0.2
373+
374+
def setup(self):
375+
self.win = 100
376+
np.random.seed(1234)
377+
self.arr = np.random.rand(100000)
378+
if (not have_real_test_parallel):
379+
raise NotImplementedError
380+
381+
def time_nogil_rolling_median(self):
382+
@test_parallel(num_threads=2)
383+
def run(arr, win):
384+
rolling_median(arr, win)
385+
run(self.arr, self.win)
386+
387+
388+
class nogil_rolling_algos_fast(object):
389+
goal_time = 0.2
390+
391+
def setup(self):
392+
self.win = 100
393+
np.random.seed(1234)
394+
self.arr = np.random.rand(1000000)
395+
if (not have_real_test_parallel):
396+
raise NotImplementedError
397+
398+
def time_nogil_rolling_mean(self):
399+
@test_parallel(num_threads=2)
400+
def run(arr, win):
401+
rolling_mean(arr, win)
402+
run(self.arr, self.win)
403+
404+
def time_nogil_rolling_min(self):
405+
@test_parallel(num_threads=2)
406+
def run(arr, win):
407+
rolling_min(arr, win)
408+
run(self.arr, self.win)
409+
410+
def time_nogil_rolling_max(self):
411+
@test_parallel(num_threads=2)
412+
def run(arr, win):
413+
rolling_max(arr, win)
414+
run(self.arr, self.win)
415+
416+
def time_nogil_rolling_var(self):
417+
@test_parallel(num_threads=2)
418+
def run(arr, win):
419+
rolling_var(arr, win)
420+
run(self.arr, self.win)
421+
422+
def time_nogil_rolling_skew(self):
423+
@test_parallel(num_threads=2)
424+
def run(arr, win):
425+
rolling_skew(arr, win)
426+
run(self.arr, self.win)
427+
428+
def time_nogil_rolling_kurt(self):
429+
@test_parallel(num_threads=2)
430+
def run(arr, win):
431+
rolling_kurt(arr, win)
432+
run(self.arr, self.win)
433+
434+
def time_nogil_rolling_std(self):
435+
@test_parallel(num_threads=2)
436+
def run(arr, win):
437+
rolling_std(arr, win)
438+
run(self.arr, self.win)

asv_bench/benchmarks/stat_ops.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,31 @@ class stats_rolling_mean(object):
231231

232232
def setup(self):
233233
self.arr = np.random.randn(100000)
234+
self.win = 100
234235

235-
def time_stats_rolling_mean(self):
236-
rolling_mean(self.arr, 100)
236+
def time_rolling_mean(self):
237+
rolling_mean(self.arr, self.win)
238+
239+
def time_rolling_median(self):
240+
rolling_median(self.arr, self.win)
241+
242+
def time_rolling_min(self):
243+
rolling_min(self.arr, self.win)
244+
245+
def time_rolling_max(self):
246+
rolling_max(self.arr, self.win)
247+
248+
def time_rolling_sum(self):
249+
rolling_sum(self.arr, self.win)
250+
251+
def time_rolling_std(self):
252+
rolling_std(self.arr, self.win)
253+
254+
def time_rolling_var(self):
255+
rolling_var(self.arr, self.win)
256+
257+
def time_rolling_skew(self):
258+
rolling_skew(self.arr, self.win)
259+
260+
def time_rolling_kurt(self):
261+
rolling_kurt(self.arr, self.win)

doc/source/whatsnew/v0.17.1.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Performance Improvements
5959

6060

6161
- Release the GIL on most datetime field operations (e.g. ``DatetimeIndex.year``, ``Series.dt.year``), normalization, and conversion to and from ``Period``, ``DatetimeIndex.to_period`` and ``PeriodIndex.to_timestamp`` (:issue:`11263`)
62-
62+
- Release the GIL on some srolling algos (``rolling_median``, ``rolling_mean``, ``rolling_max``, ``rolling_min``, ``rolling_var``, ``rolling_kurt``, `rolling_skew`` (:issue:`11450`)
63+
- Improved performance of ``rolling_median`` (:issue:`11450`)
6364

6465
- Improved performance to ``to_excel`` (:issue:`11352`)
6566

0 commit comments

Comments
 (0)