CLN: ASV Algorithms benchmark
State: closed

High Level changes:

- The `Algorithms` class benchmark was getting large so I broke it into several smaller classes, avoiding creating data structures in each `setup` call that would only be used for 1 benchmark.

- Added `np.random.seed(1234)` in `setup` classes where random data is created xref #8144

- Utilized `params` and `setup_cache` where applicable.

- Added additional hashing benchmarks

The benchmarks should be equivalent to what existed before. If the diff is too large I can break it up into smaller PRs. You can find 3 asv runs below. 

<details>

```
$ asv run -b ^algorithms -q

[  5.26%] ··· Running algorithms.Hashing.time_frame                                                     58.8ms
[ 10.53%] ··· Running algorithms.Hashing.time_series_categorical                                        15.6ms
[ 15.79%] ··· Running algorithms.Hashing.time_series_dates                                              10.3ms
[ 21.05%] ··· Running algorithms.Hashing.time_series_float                                              13.7ms
[ 26.32%] ··· Running algorithms.Hashing.time_series_int                                                11.0ms
[ 31.58%] ··· Running algorithms.Hashing.time_series_string                                             29.7ms
[ 36.84%] ··· Running algorithms.Hashing.time_series_timedeltas                                         13.4ms
[ 42.11%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_mask_nan                        45.8ms
[ 47.37%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_rev                             32.5ms
[ 52.63%] ··· Running algorithms.AddOverflowArray.time_add_overflow_b_mask_nan                          43.2ms
[ 57.89%] ··· Running algorithms.AddOverflowArray.time_add_overflow_both_arg_nan                        40.2ms
[ 63.16%] ··· Running algorithms.AddOverflowScalar.time_add_overflow_scalar                         25.8ms;...
[ 68.42%] ··· Running algorithms.Duplicated.time_duplicated_float                                       40.1ms
[ 73.68%] ··· Running algorithms.Duplicated.time_duplicated_int                                         26.3ms
[ 78.95%] ··· Running algorithms.DuplicatedUniqueIndex.time_duplicated_unique_int                        374μs
[ 84.21%] ··· Running algorithms.Factorize.time_factorize_float                                         27.8ms
[ 89.47%] ··· Running algorithms.Factorize.time_factorize_int                                           18.3ms
[ 94.74%] ··· Running algorithms.Factorize.time_factorize_string                                        52.3ms
[100.00%] ··· Running algorithms.Match.time_match_string                                                 902μs

asv run -b ^algorithms -q
[  5.26%] ··· Running algorithms.Hashing.time_frame                                                     58.7ms
[ 10.53%] ··· Running algorithms.Hashing.time_series_categorical                                        12.4ms
[ 15.79%] ··· Running algorithms.Hashing.time_series_dates                                              9.24ms
[ 21.05%] ··· Running algorithms.Hashing.time_series_float                                              9.53ms
[ 26.32%] ··· Running algorithms.Hashing.time_series_int                                                9.53ms
[ 31.58%] ··· Running algorithms.Hashing.time_series_string                                             29.1ms
[ 36.84%] ··· Running algorithms.Hashing.time_series_timedeltas                                         9.57ms
[ 42.11%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_mask_nan                        47.3ms
[ 47.37%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_rev                             26.5ms
[ 52.63%] ··· Running algorithms.AddOverflowArray.time_add_overflow_b_mask_nan                          38.9ms
[ 57.89%] ··· Running algorithms.AddOverflowArray.time_add_overflow_both_arg_nan                        39.6ms
[ 63.16%] ··· Running algorithms.AddOverflowScalar.time_add_overflow_scalar                         24.2ms;...
[ 68.42%] ··· Running algorithms.Duplicated.time_duplicated_float                                       40.1ms
[ 73.68%] ··· Running algorithms.Duplicated.time_duplicated_int                                         28.5ms
[ 78.95%] ··· Running algorithms.DuplicatedUniqueIndex.time_duplicated_unique_int                        450μs
[ 84.21%] ··· Running algorithms.Factorize.time_factorize_float                                         31.6ms
[ 89.47%] ··· Running algorithms.Factorize.time_factorize_int                                           18.6ms
[ 94.74%] ··· Running algorithms.Factorize.time_factorize_string                                        56.0ms
[100.00%] ··· Running algorithms.Match.time_match_string                                                 788μs

asv run -b ^algorithms -q
[  5.26%] ··· Running algorithms.Hashing.time_frame                                                     57.4ms
[ 10.53%] ··· Running algorithms.Hashing.time_series_categorical                                        13.3ms
[ 15.79%] ··· Running algorithms.Hashing.time_series_dates                                              12.5ms
[ 21.05%] ··· Running algorithms.Hashing.time_series_float                                              9.70ms
[ 26.32%] ··· Running algorithms.Hashing.time_series_int                                                9.27ms
[ 31.58%] ··· Running algorithms.Hashing.time_series_string                                             30.0ms
[ 36.84%] ··· Running algorithms.Hashing.time_series_timedeltas                                         15.8ms
[ 42.11%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_mask_nan                        40.5ms
[ 47.37%] ··· Running algorithms.AddOverflowArray.time_add_overflow_arr_rev                             25.5ms
[ 52.63%] ··· Running algorithms.AddOverflowArray.time_add_overflow_b_mask_nan                          38.7ms
[ 57.89%] ··· Running algorithms.AddOverflowArray.time_add_overflow_both_arg_nan                        44.5ms
[ 63.16%] ··· Running algorithms.AddOverflowScalar.time_add_overflow_scalar                         20.3ms;...
[ 68.42%] ··· Running algorithms.Duplicated.time_duplicated_float                                       45.3ms
[ 73.68%] ··· Running algorithms.Duplicated.time_duplicated_int                                         33.3ms
[ 78.95%] ··· Running algorithms.DuplicatedUniqueIndex.time_duplicated_unique_int                        332μs
[ 84.21%] ··· Running algorithms.Factorize.time_factorize_float                                         26.2ms
[ 89.47%] ··· Running algorithms.Factorize.time_factorize_int                                           18.5ms
[ 94.74%] ··· Running algorithms.Factorize.time_factorize_string                                        55.5ms
[100.00%] ··· Running algorithms.Match.time_match_string                                                 800μs
```

</details>




Labels:
name: Benchmark
description: Performance (ASV) benchmarks

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=h1) Report
> Merging [#18423](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/103ea6fa33cbee3d9a193010016faa4cec7abf87?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18423/graphs/tree.svg?token=eZ4WkYLtcO&width=650&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18423      +/-   ##
==========================================
- Coverage   91.35%   91.31%   -0.05%     
==========================================
  Files         163      163              
  Lines       49714    49714              
==========================================
- Hits        45415    45394      -21     
- Misses       4299     4320      +21
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.1% <ø> (-0.03%)` | :arrow_down: |
| #single | `39.63% <ø> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.44% <0%> (-1.82%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=footer). Last update [103ea6f...a7858e3](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=h1) Report
> Merging [#18423](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/be66ef832ef551d118a8e219a9e98928681df835?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18423/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18423      +/-   ##
==========================================
- Coverage   91.33%   91.32%   -0.02%     
==========================================
  Files         163      163              
  Lines       49752    49717      -35     
==========================================
- Hits        45443    45404      -39     
- Misses       4309     4313       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.12% <ø> (ø)` | :arrow_up: |
| #single | `40.51% <ø> (-0.27%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/indexes/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9pbnRlcnZhbC5weQ==) | `92.64% <0%> (-0.06%)` | :arrow_down: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `91.17% <0%> (-0.04%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.49% <0%> (-0.04%)` | :arrow_down: |
| [pandas/core/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYmFzZS5weQ==) | `96.56% <0%> (+0.02%)` | :arrow_up: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.43% <0%> (+0.03%)` | :arrow_up: |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.59% <0%> (+0.07%)` | :arrow_up: |
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `94.84% <0%> (+0.07%)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.11% <0%> (+0.19%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=footer). Last update [be66ef8...35c7af4](https://codecov.io/gh/pandas-dev/pandas/pull/18423?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jorisvandenbossche for `Factorize` and `Duplicated` classed I added param arguments over their `sort` and `keep` kwags respectively for a little more motivation to keep them as separate classes. I think there may be cases in the future where specific Index data might want to be run on one method and not the other. 
thanks @mroeschke