This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |