Convenient printing of time elapsed. A wrapper of data.table::timetaken, but showing the results more directly.

sys_time_print(expr)

Arguments

expr

Valid R expression to be timed.

Value

A character vector of the form HH:MM:SS, or SS.MMMsec if under 60 seconds. See examples.

See also

Examples

sys_time_print(Sys.sleep(1))
#> [1] "Finished in 1.010s elapsed (0.000s cpu)"
a = as.data.table(iris) sys_time_print({ res = a %>% mutate(one = 1) })
#> [1] "Finished in 0.000s elapsed (0.000s cpu)"
res
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species one #> <num> <num> <num> <num> <fctr> <num> #> 1: 5.1 3.5 1.4 0.2 setosa 1 #> 2: 4.9 3.0 1.4 0.2 setosa 1 #> 3: 4.7 3.2 1.3 0.2 setosa 1 #> 4: 4.6 3.1 1.5 0.2 setosa 1 #> 5: 5.0 3.6 1.4 0.2 setosa 1 #> --- #> 146: 6.7 3.0 5.2 2.3 virginica 1 #> 147: 6.3 2.5 5.0 1.9 virginica 1 #> 148: 6.5 3.0 5.2 2.0 virginica 1 #> 149: 6.2 3.4 5.4 2.3 virginica 1 #> 150: 5.9 3.0 5.1 1.8 virginica 1