Skip to content

Commit e36e03b

Browse files
committed
- adding benchmark files
1 parent e29bd98 commit e36e03b

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

asv_bench/asv.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"xlwt": [],
5454
"odfpy": [],
5555
"pytest": [],
56+
"jinja2": [],
5657
// If using Windows with python 2.7 and want to build using the
5758
// mingw toolchain (rather than MSVC), uncomment the following line.
5859
// "libpython": [],

asv_bench/benchmarks/io/style.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import numpy as np
2+
3+
from pandas import DataFrame
4+
5+
from ..pandas_vb_common import BaseIO, tm
6+
7+
8+
class RenderApply(BaseIO):
9+
10+
params = [[12, 24, 36], [12, 120, 1200]]
11+
param_names = ["cols", "rows"]
12+
13+
def setup(self, cols, rows):
14+
self.df = DataFrame(
15+
np.random.randn(rows, cols),
16+
columns=[f"float_{i}" for i in range(cols)],
17+
index=np.arange(rows),
18+
)
19+
self._style_apply()
20+
21+
def time_apply(self, cols, rows):
22+
self._style_apply()
23+
24+
def time_render(self, cols, rows):
25+
self.st.render()
26+
27+
def peakmem_apply(self, cols, rows):
28+
self._style_apply()
29+
30+
def peakmem_render(self, cols, rows):
31+
self.st.render()
32+
33+
def _style_apply(self):
34+
def _apply_func(s):
35+
a, b = [x for x in s]
36+
return [
37+
'color: red' if a > b else '',
38+
'color: red' if a < b else '',
39+
]
40+
self.st = self.df.style.apply(
41+
_apply_func, axis=1, subset=['float_3', 'float_4']
42+
)
43+
44+
45+
from ..pandas_vb_common import setup # noqa: F401 isort:skip

0 commit comments

Comments
 (0)