Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions asv_bench/benchmarks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import numpy as np
import pandas.util.testing as tm
from pandas import (Series, DataFrame, Panel, MultiIndex, Int64Index,
Float64Index, IntervalIndex, CategoricalIndex,
from pandas import (Series, DataFrame, Panel, MultiIndex,
Int64Index, UInt64Index, Float64Index,
IntervalIndex, CategoricalIndex,
IndexSlice, concat, date_range)


class NumericSeriesIndexing(object):

goal_time = 0.2
params = [
(Int64Index, Float64Index),
(Int64Index, UInt64Index, Float64Index),
('unique_monotonic_inc', 'nonunique_monotonic_inc'),
]
param_names = ['index_dtype', 'index_structure']
Expand Down
54 changes: 54 additions & 0 deletions asv_bench/benchmarks/indexing_engines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import numpy as np

from pandas._libs.index import (Int64Engine, UInt64Engine, Float64Engine,
ObjectEngine)


class NumericEngineIndexing(object):

goal_time = 0.2
params = [[Int64Engine, UInt64Engine, Float64Engine],
[np.int64, np.uint64, np.float64],
['monotonic_incr', 'monotonic_decr', 'non_monotonic'],
]
param_names = ['engine', 'dtype', 'index_type']

def setup(self, engine, dtype, index_type):
N = 10**5
values = list([1] * N + [2] * N + [3] * N)
arr = {
'monotonic_incr': np.array(values, dtype=dtype),
'monotonic_decr': np.array(list(reversed(values)),
dtype=dtype),
'non_monotonic': np.array([1, 2, 3] * N, dtype=dtype),
}[index_type]

self.data = engine(lambda: arr, len(arr))
# code belows avoids populating the mapping etc. while timing.
self.data.get_loc(2)

def time_get_loc(self, engine, dtype, index_type):
self.data.get_loc(2)


class ObjectEngineIndexing(object):

goal_time = 0.2
params = [('monotonic_incr', 'monotonic_decr', 'non_monotonic')]
param_names = ['index_type']

def setup(self, index_type):
N = 10**5
values = list('a' * N + 'b' * N + 'c' * N)
arr = {
'monotonic_incr': np.array(values, dtype=object),
'monotonic_decr': np.array(list(reversed(values)), dtype=object),
'non_monotonic': np.array(list('abc') * N, dtype=object),
}[index_type]

self.data = ObjectEngine(lambda: arr, len(arr))
# code belows avoids populating the mapping etc. while timing.
self.data.get_loc('b')

def time_get_loc(self, index_type):
self.data.get_loc('b')