R语言记录程序运行的时间

f <- function(start_time) {
  start_time <- as.POSIXct(start_time)
  dt <- difftime(Sys.time(), start_time, units="secs")
  # Since you only want the H:M:S, we can ignore the date...
  # but you have to be careful about time-zone issues
  format(.POSIXct(dt,tz="GMT"), "%H:%M:%S")
}


how to use:

time1<-Sys.time()
...

f(time1)
posted @ 2014-07-22 18:13  emanlee  阅读(9214)  评论(0编辑  收藏  举报