R/tic.R

#' Timer function (as in MATLAB)
#' 
#' Function to start a timer.  Stop with toc().
#' 
#' @param gcFirst Perform garbage collection?
#' @param name The saved name of the time object.
#' 
#' @note This is a modified version of the same function in the matlab R-package.
#' 
#' @family MATLAB
#' @example tests/testthat/examples_fcn_doc/examples_tic.R
#' @export
## Function written to match MATLAB function
## Author: Andrew Hooker

#tic <- function(...){
#    return(matlab::tic())
#}

tic <- function (gcFirst = FALSE,name=".poped_savedTime") 
{
  if (gcFirst == TRUE) {
    gc(verbose = FALSE)
  }
  
  #   if(exists(envir)){
  #     if(!is.environment(eval(parse(text=envir)))) eval(parse(text=envir)) <- new.env(parent=baseenv())
  #   } else {
  #.PopEDNamespaceEnv <- new.env(parent=.GlobalEnv)
  #   }
  #   if(!exists(name,envir=.PopEDNamespaceEnv)){
  #   .PopEDNamespaceEnv <- new.env(parent=baseenv())
  #   }
  assign(name, proc.time()[3], envir = .PopedNamespaceEnv)
  
  #assign(name, proc.time()[3], pos = package:PopED)
  
  #assign(name, proc.time()[3], pos = eval(parse(text="1")))
  invisible()
}

Try the PopED package in your browser

Any scripts or data that you put into this service are public.

PopED documentation built on May 21, 2021, 5:08 p.m.