knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.height = 6,
  fig.width = 6
)
library(ggplot2)
theme_here = theme_bw(base_size = 12) +
  theme(panel.grid.minor = element_blank(),
        axis.ticks = element_blank(),
        strip.background = element_rect(linetype = 0))
theme_set(theme_here)

Run simulation with benchmark information

library(tidyverse)
library(tumopp)

.const = list(D = 3, C = "hex", k = 10, N = 2 ** 17, benchmark = TRUE)
.alt = list(
  L = c("const", "linear"),
  P = c("random", "mindrag"),
  d = c(0, 0.2),
  m = c(0, 2)
)
args_tbl = make_args(alt = .alt, const = .const) |> print()

results = tumopp::tumopp(args_tbl, graph = FALSE) |> print()

unnested = results |>
  dplyr::select(!c(population, seed)) |>
  dplyr::mutate(outdir = fs::path_file(outdir)) |>
  dplyr::select(where(\(x) dplyr::n_distinct(x) > 1L)) |>
  tidyr::unnest(benchmark) |>
  print()

df_benchmark = unnested |>
  dplyr::distinct(outdir, size, .keep_all = TRUE) |>
  dplyr::mutate(
    local = factor(local, levels = .alt[["L"]]),
    path = factor(path, levels = .alt[["P"]]),
    size = size / 1000,      # to K
    memory = maxrss / 1024,  # K to M
    utime = utime / 1000,    # ms to sec
    stime = stime / 1000,    # ms to sec
    maxrss = NULL
  ) |>
  print()

# usethis::use_data(df_benchmark, internal = TRUE, overwrite = TRUE)

Memory

ggplot(tumopp:::df_benchmark) +
  aes(size, memory) +
  geom_line(linewidth = 1, color = "#337ab7") +
  facet_grid(vars(local, path), vars(delta0, rho0), label = label_both) +
  labs(x = "Size (K cells)", y = "Memory (MB)")

Time

ggplot(tumopp:::df_benchmark) +
  aes(size, utime + stime) +
  geom_line(linewidth = 1, color = "#337ab7") +
  facet_grid(vars(local, path), vars(delta0, rho0), label = label_both) +
  labs(x = "Size (K cells)", y = "Time (sec)")


heavywatal/tumorr documentation built on April 2, 2024, 7:24 p.m.