Created
June 16, 2020 12:37
-
-
Save tonyelhabr/07f64a93cccfd4dfd4f14df51f75af27 to your computer and use it in GitHub Desktop.
Simple logic for pretty time-to-complete message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
start <- Sys.time() | |
end <- Sys.time() | |
dur <- (end - start) %>% lubridate::as.duration() | |
dur_s <- round(as.numeric(dur, 'seconds'), 1) %>% scales::comma() | |
dur_m <- round(as.numeric(dur, 'minutes'), 1) %>% scales::comma() | |
cat(glue::glue('action took {dur_s} seconds ({dur_m} minutes) to complete.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment