Skip to content

Commit

Permalink
another fix for utilization calculation with zero capacity, closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Oct 31, 2021
1 parent 74ed7dc commit 7eef661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
@@ -1,7 +1,7 @@
# simmer.plot 0.1.16.9000
# simmer.plot 0.1.17

- Fix calculation of resource utilization when zero capacity values are present
(#22 addressing #21).
(#22 addressing #21; #24).

# simmer.plot 0.1.16

Expand Down
5 changes: 3 additions & 2 deletions R/plot.resources.R
Expand Up @@ -80,9 +80,10 @@ plot.resources.usage <- function(x, items=c("queue", "server", "system"), steps=
plot.resources.utilization <- function(x) {
x <- x %>%
dplyr::group_by(.data$resource, .data$replication) %>%
dplyr::mutate(dt = .data$time - dplyr::lag(.data$time)) %>%
dplyr::mutate(dt = dplyr::lead(.data$time) - .data$time) %>%
dplyr::mutate(capacity = ifelse(.data$capacity < .data$server, .data$server, .data$capacity)) %>%
dplyr::mutate(in_use = .data$dt * dplyr::lag(.data$server / .data$capacity)) %>%
dplyr::mutate(dt = ifelse(.data$capacity > 0, .data$dt, 0)) %>%
dplyr::mutate(in_use = .data$dt * .data$server / .data$capacity) %>%
dplyr::summarise(utilization = sum(.data$in_use, na.rm = TRUE) / sum(.data$dt, na.rm=TRUE)) %>%
dplyr::summarise(Q25 = stats::quantile(.data$utilization, .25),
Q50 = stats::quantile(.data$utilization, .5),
Expand Down

0 comments on commit 7eef661

Please sign in to comment.