Skip to content

Commit

Permalink
Refactor asv tests for Series.asof. Add asv tests for DataFrame.asof
Browse files Browse the repository at this point in the history
  • Loading branch information
laudney committed Oct 24, 2016
1 parent 4d5f6d7 commit 6fda9c9
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions asv_bench/benchmarks/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,56 +284,54 @@ class timeseries_asof(object):
goal_time = 0.2

def setup(self):
self.N = 100000
self.rng = date_range(start='1/1/2000', periods=self.N, freq='T')
if hasattr(Series, 'convert'):
Series.resample = Series.convert
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.N = 10000
self.rng = date_range(start='1/1/1990', periods=self.N, freq='53s')
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.dates = date_range(start='1/1/1990', periods=(self.N * 10), freq='5s')
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.ts2 = self.ts.copy()
self.ts2[250:5000] = np.nan
self.ts3 = self.ts.copy()
self.ts3[-5000:] = np.nan

def time_timeseries_asof(self):
def time_asof_list(self):
self.ts.asof(self.dates)

def time_asof_single(self):
self.ts.asof(self.dates[0])

class timeseries_asof_nan(object):
goal_time = 0.2
def time_asof_nan_list(self):
self.ts2.asof(self.dates)

def setup(self):
self.N = 100000
self.rng = date_range(start='1/1/2000', periods=self.N, freq='T')
if hasattr(Series, 'convert'):
Series.resample = Series.convert
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.N = 10000
self.rng = date_range(start='1/1/1990', periods=self.N, freq='53s')
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.dates = date_range(start='1/1/1990', periods=(self.N * 10), freq='5s')
self.ts[250:5000] = np.nan

def time_timeseries_asof_nan(self):
self.ts.asof(self.dates)
def time_asof_nan_single(self):
self.ts3.asof(self.dates[-1])


class timeseries_asof_single(object):
class timeseries_dataframe_asof(object):
goal_time = 0.2

def setup(self):
self.N = 100000
self.rng = date_range(start='1/1/2000', periods=self.N, freq='T')
if hasattr(Series, 'convert'):
Series.resample = Series.convert
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.N = 10000
self.M = 100
self.rng = date_range(start='1/1/1990', periods=self.N, freq='53s')
self.ts = Series(np.random.randn(self.N), index=self.rng)
self.dates = date_range(start='1/1/1990', periods=(self.N * 10), freq='5s')
self.ts = DataFrame(np.random.randn(self.N * self.M).reshape((self.N, self.M)), index=self.rng)
self.ts2 = self.ts.copy()
self.ts2.iloc[250:5000] = np.nan
self.ts3 = self.ts.copy()
self.ts3.iloc[-5000:] = np.nan

def time_timeseries_asof_single(self):
def time_asof_list(self):
self.ts.asof(self.dates)

def time_asof_single(self):
self.ts.asof(self.dates[0])

def time_asof_nan_list(self):
self.ts2.asof(self.dates)

def time_asof_nan_single(self):
self.ts3.asof(self.dates[-1])


class timeseries_custom_bday_apply(object):
goal_time = 0.2
Expand Down

0 comments on commit 6fda9c9

Please sign in to comment.