Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
Merge 71ee3e4 into 5fba799
Browse files Browse the repository at this point in the history
  • Loading branch information
densmirn committed Aug 29, 2019
2 parents 5fba799 + 71ee3e4 commit 2903e41
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
Empty file added tests_perf/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions tests_perf/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from enum import Enum

import numba

import hpat


class Implementation(Enum):
native = 'native'
njit = 'njit'
hpat = 'hpat'


class ImplRunner:
def __init__(self, implementation, func):
self.implementation = implementation
self.func = func

@property
def runner(self):
if self.implementation == Implementation.hpat.value:
return hpat.jit(self.func)
elif self.implementation == Implementation.njit.value:
return numba.njit(self.func)
elif self.implementation == Implementation.native.value:
return self.func

raise ValueError(f'Unknown implementation: {self.implementation}')

def run(self, *args, **kwargs):
return self.runner(*args, **kwargs)
27 changes: 27 additions & 0 deletions tests_perf/unicode_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pandas.util import testing as tm

from .common import Implementation, ImplRunner


class Methods:
params = [Implementation.native.value, Implementation.njit.value]
param_names = ['implementation']

def setup(self, implementation):
self.s = tm.randu(10 ** 4)
self.width = 10 ** 8

def time_center(self, implementation):
def _center(s, width):
return s.center(width)
ImplRunner(implementation, _center).run(self.s, self.width)

def time_ljust(self, implementation):
def _ljust(s, width):
return s.ljust(width)
ImplRunner(implementation, _ljust).run(self.s, self.width)

def time_rjust(self, implementation):
def _rjust(s, width):
return s.ljust(width)
ImplRunner(implementation, _rjust).run(self.s, self.width)

0 comments on commit 2903e41

Please sign in to comment.