Skip to content

CLN: ASV categoricals benchmark #18465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2017

Conversation

mroeschke
Copy link
Member

  • Split classes from Categoricals/2/3 --> Concat, ValueCounts, Rank, Repr, SetCategories, and Constructor

  • Utilized params and param_names for ValueCounts

  • Added np.random.seed(1234) in setup classes where random data is created xref BENCH: put in np.random.seed on vbenches #8144

  • Ran flake8 and replaced star imports

$ asv run -q -b ^categoricals
[  0.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[  5.88%] ··· Running categoricals.Concat.time_concat                                                                               14.2ms
[ 11.76%] ··· Running categoricals.Concat.time_union                                                                                12.2ms
[ 17.65%] ··· Running categoricals.Constructor.time_constructor_all_nan                                                             54.7ms
[ 23.53%] ··· Running categoricals.Constructor.time_constructor_datetimes                                                           2.22ms
[ 29.41%] ··· Running categoricals.Constructor.time_constructor_datetimes_with_nat                                                  2.32ms
[ 35.29%] ··· Running categoricals.Constructor.time_constructor_fastpath                                                            1.59ms
[ 41.18%] ··· Running categoricals.Constructor.time_constructor_regular                                                             48.8ms
[ 47.06%] ··· Running categoricals.Constructor.time_constructor_with_nan                                                             510ms
[ 52.94%] ··· Running categoricals.Rank.time_rank_int                                                                               11.7ms
[ 58.82%] ··· Running categoricals.Rank.time_rank_int_cat                                                                           12.9ms
[ 64.71%] ··· Running categoricals.Rank.time_rank_int_cat_ordered                                                                   12.2ms
[ 70.59%] ··· Running categoricals.Rank.time_rank_string                                                                             520ms
[ 76.47%] ··· Running categoricals.Rank.time_rank_string_cat                                                                        18.3ms
[ 82.35%] ··· Running categoricals.Rank.time_rank_string_cat_ordered                                                                10.2ms
[ 88.24%] ··· Running categoricals.Repr.time_rendering                                                                              1.58ms
[ 94.12%] ··· Running categoricals.SetCategories.time_set_categories                                                                70.7ms
[100.00%] ··· Running categoricals.ValueCounts.time_value_counts                                                                81.2ms;...

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean-up! Left a few comments

try:
from pandas.types.concat import union_categoricals
except ImportError:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you leave this try .. except in place? It is meant to be able to run the benchmarks with different older versions

np.random.seed(2718281)
arr = ['s%04d' % i for i in np.random.randint(0, n // 10, size=n)]
self.ts = Series(arr).astype('category')
self.ts = pd.Series(arr).astype('category')
self.dropna = dropna
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed I think? You can directly use the arg dropna in the time method

self.dropna = dropna

def time_value_counts(self, dropna):
self.ts.value_counts(dropna=self.dropna)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.dropna -> dropna

@jorisvandenbossche jorisvandenbossche added the Benchmark Performance (ASV) benchmarks label Nov 24, 2017

def time_union(self):
union_categoricals([self.a, self.b])

def time_constructor_regular(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we wan to remove the _constructor part in the time names? As you already have it in the class name (now you have 'constructor' twice and making the name long)

@codecov
Copy link

codecov bot commented Nov 24, 2017

Codecov Report

Merging #18465 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18465      +/-   ##
==========================================
- Coverage   91.34%   91.32%   -0.02%     
==========================================
  Files         163      163              
  Lines       49717    49717              
==========================================
- Hits        45413    45404       -9     
- Misses       4304     4313       +9
Flag Coverage Δ
#multiple 89.12% <ø> (ø) ⬆️
#single 40.51% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.8% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 412988e...3fcf30f. Read the comment docs.

@mroeschke mroeschke force-pushed the asv_clean_categoricals branch from b73774c to 3fcf30f Compare November 25, 2017 00:44
@mroeschke
Copy link
Member Author

Kept the removed imports, changed the redundant method names, and changed self.dropna -> dropna

@jreback jreback added this to the 0.22.0 milestone Nov 25, 2017
@jreback jreback merged commit 200227e into pandas-dev:master Nov 25, 2017
@jreback
Copy link
Contributor

jreback commented Nov 25, 2017

thanks!

@mroeschke mroeschke deleted the asv_clean_categoricals branch November 25, 2017 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Benchmark Performance (ASV) benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants