From 5adf7a3fe0684d73f38c6a17afe3582006408acb Mon Sep 17 00:00:00 2001 From: Michael Schubert Date: Sat, 9 Dec 2023 23:46:39 +0100 Subject: [PATCH] fix stats summary --- R/pool.r | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/R/pool.r b/R/pool.r index dba015d..70cce85 100644 --- a/R/pool.r +++ b/R/pool.r @@ -100,18 +100,19 @@ Pool = R6::R6Class("Pool", }, cleanup = function(timeout=5000) { + info = self$info() private$master$close(timeout) # ^^ replace with: (1) try close connections, and (2) close socket - times = private$master$list_workers()$time - times = times[sapply(times, length) != 0] - max_mem = max(c(self$info()[["mem.max"]]+2e8, 0), na.rm=TRUE) # add 200 Mb + max_mem = max(c(info$mem.max+2e8, 0), na.rm=TRUE) # add 200 Mb max_mem_str = format(structure(max_mem, class="object_size"), units="auto") - wt = Reduce(`+`, times) / length(times) - rt = proc.time() - private$timer - if (! inherits(wt, "proc_time")) + if (nrow(info) > 0) { + wt = lapply(info[c("user.self", "sys.self", "elapsed")], mean, na.rm=TRUE) + } else { wt = rep(NA, 3) + } + rt = proc.time() - private$timer rt3_fmt = difftime(as.POSIXct(rt[[3]], origin="1970-01-01"), as.POSIXct(0, origin="1970-01-01"), units="auto") rt3_str = sprintf("%.1f %s", rt3_fmt, attr(rt3_fmt, "units"))