diff --git a/NEWS.md b/NEWS.md index 8b1459a..687c0a1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pingr (development version) +* `ping()` now handles sub-millisecond response times (#24). + # pingr 2.0.3 * `ping_port()` now correctly prints the port if `version = TRUE`. diff --git a/R/ping-package.R b/R/ping-package.R index d594cee..b3c69c2 100644 --- a/R/ping-package.R +++ b/R/ping-package.R @@ -72,7 +72,7 @@ ping <- function(destination, continuous = FALSE, verbose = continuous, if (!continuous) { timings <- grep(os$regex, output, value = TRUE, perl = TRUE) - times <- sub(os$regex, "\\1", timings, perl = TRUE) + times <- sub(os$regex, "\\2", timings, perl = TRUE) res <- as.numeric(times) length(res) <- count res @@ -132,7 +132,7 @@ ping_os <- function(destination, continuous, count, timeout) { ) } - list(cmd = cmd, env = env, regex = "^.*time=(.+)[ ]?ms.*$") + list(cmd = cmd, env = env, regex = "^.*time(=|<)(.+)[ ]?ms.*$") } #' Is the computer online?