andrewallenbruce / northstar

Tidy Healthcare Revenue Integrity :compass:
https://andrewallenbruce.github.io/northstar/
Apache License 2.0
4 stars 0 forks source link

benchmarking func versions #1

Closed andrewallenbruce closed 6 months ago

andrewallenbruce commented 8 months ago

All args used:

library(bench)
library(dplyr)
library(northstar)

hcpcs    = c("39503", "43116", "33935", "11646", "70170", "V5299")
state    = "GA"
locality = "99"
mac      = "10212"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs    = hcpcs,
    state    = state,
    locality = locality,
    mac      = mac
  ),
  old = northstar:::hcpcs_search(
    hcpcs    = hcpcs,
    state    = state,
    locality = locality,
    mac      = mac
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new           1.85s    2.25s     0.452     140MB     1.36
#> 2 old           1.84s     1.9s     0.526     126MB     1.58

Created on 2024-03-26 with reprex v2.1.0

andrewallenbruce commented 8 months ago

one CPT, HCPCS and one state

library(bench)
library(dplyr)
library(northstar)

hcpcs = c("70170", "V5299")
state = "GA"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs = hcpcs,
    state = state
  ),
  old = northstar:::hcpcs_search(
    hcpcs = hcpcs,
    state = state
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new            1.7s    1.76s     0.549     140MB     1.21
#> 2 old           1.69s    1.75s     0.572     126MB     1.14

Created on 2024-03-26 with reprex v2.1.0

andrewallenbruce commented 8 months ago

All args used:

library(bench)
library(dplyr)
library(northstar)

hcpcs    = c("39503", "43116", "33935", "11646", "70170", "V5299")
state    = "GA"
locality = "99"
mac      = "10212"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs    = hcpcs,
    state    = state,
    locality = locality,
    mac      = mac
  ),
  old = northstar:::hcpcs_search(
    hcpcs    = hcpcs,
    state    = state,
    locality = locality,
    mac      = mac
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new           1.85s    2.25s     0.452     140MB     1.36
#> 2 old           1.84s     1.9s     0.526     126MB     1.58

Created on 2024-03-26 with reprex v2.1.0

library(bench)
library(dplyr)
library(northstar)

hcpcs    = c("39503", "43116", "33935", "11646", "70170", "V5299")
state    = "GA"
locality = "99"
mac      = "10212"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs    = hcpcs,
    state    = state,
    locality = locality,
    mac      = mac
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new           125ms    163ms      5.88    12.4MB     1.47

Created on 2024-03-26 with reprex v2.1.0

andrewallenbruce commented 8 months ago

one CPT, HCPCS and one state

library(bench)
library(dplyr)
library(northstar)

hcpcs = c("70170", "V5299")
state = "GA"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs = hcpcs,
    state = state
  ),
  old = northstar:::hcpcs_search(
    hcpcs = hcpcs,
    state = state
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new            1.7s    1.76s     0.549     140MB     1.21
#> 2 old           1.69s    1.75s     0.572     126MB     1.14

Created on 2024-03-26 with reprex v2.1.0

library(bench)
library(dplyr)
library(northstar)

hcpcs = c("70170", "V5299")
state = "GA"

bench::mark(
  new = northstar::search_hcpcs(
    hcpcs    = hcpcs,
    state    = state
  ),
  min_iterations = 10
) |>
  dplyr::select(expression:total_time)

#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 new           127ms    135ms      7.40    12.4MB     1.85

Created on 2024-03-26 with reprex v2.1.0

andrewallenbruce commented 5 months ago
library(fuimus)
library(bench)
#> Warning: package 'bench' was built under R version 4.3.3
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(kit)
#> Warning: package 'kit' was built under R version 4.3.3
#> Attaching kit 0.0.17 (OPENMP enabled using 1 thread)
#> 
#> Attaching package: 'kit'
#> The following object is masked from 'package:dplyr':
#> 
#>     count

ex <- fuimus::pad_number(c(1:11, 88, 99))
x <- sample(ex, 1e7, replace = TRUE)

bench::mark(
  kit = kit::nswitch(
    x = x,
    "01", "Ultrasound (Chest / Abdomen / Pelvis-Non-Obstetrical)",
    "02", "CT and CTA (Chest / Thorax / Abd / Pelvis)",
    "03", "CT and CTA (Head / Brain / Orbit / Maxillofacial / Neck)",
    "04", "MRI and MRA (Chest / Abd / Pelvis)",
    "05", "MRI and MRA (Head / Brain / Neck)",
    "06", "MRI and MRA (Spine)",
    "07", "CT (Spine)",
    "08", "MRI and MRA (Lower Extremities)",
    "09", "CT and CTA (Lower Extremities)",
    "10", "MRI and MRA (Upper Extremities and Joints)",
    "11", "CT and CTA (Upper Extremities)",
    "88", "Subject to Reduction of TC or PC Diagnostic Imaging",
    "99", "Concept does not apply",
    default = NA_character_
  ),
  dplyr = dplyr::case_match(
    x,
    "01" ~ "Ultrasound (Chest / Abdomen / Pelvis-Non-Obstetrical)",
    "02" ~ "CT and CTA (Chest / Thorax / Abd / Pelvis)",
    "03" ~ "CT and CTA (Head / Brain / Orbit / Maxillofacial / Neck)",
    "04" ~ "MRI and MRA (Chest / Abd / Pelvis)",
    "05" ~ "MRI and MRA (Head / Brain / Neck)",
    "06" ~ "MRI and MRA (Spine)",
    "07" ~ "CT (Spine)",
    "08" ~ "MRI and MRA (Lower Extremities)",
    "09" ~ "CT and CTA (Lower Extremities)",
    "10" ~ "MRI and MRA (Upper Extremities and Joints)",
    "11" ~ "CT and CTA (Upper Extremities)",
    "88" ~ "Subject to Reduction of TC or PC Diagnostic Imaging",
    "99" ~ "Concept does not apply",
    .default = NA_character_
  )
) |> 
  dplyr::select(expression:total_time)
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 kit        368.26ms  414.4ms     2.41     76.3MB     0   
#> 2 dplyr         3.45s    3.45s     0.290    2.16GB     1.45

Created on 2024-05-29 with reprex v2.1.0