Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

umx_time

umx_time


Description

A function to compactly report how long a model took to execute. Comes with some preset styles User can set the format with C-style string formatting.

Usage

umx_time(
  x = NA,
  formatStr = c("simple", "std", "custom %H %M %OS3"),
  tz = "GMT",
  autoRun = TRUE
)

Arguments

x

A mxModel() or list of models for which to display elapsed time, or 'start' or 'stop'

formatStr

A format string, defining how to show the time (defaults to human readable)

tz

time zone in which the model was executed (defaults to "GMT")

autoRun

If TRUE (default), run the model if it appears not to have been.

Details

The default time format is "simple", which gives only the biggest unit used. i.e., "x seconds" for times under 1 minute. "std" shows time in the format adopted in OpenMx 2.0 e.g. "Wall clock time (HH:MM:SS.hh): 00:00:01.16"

If a list of models is provided, time deltas will also be reported.

If instead of a model the key word "start" is given in x, a start time will be recorded. "stop" gives the time since "start" was called (and clears the timer)

If a model has not been run, umx_time will run it for you.

Value

  • invisible time string

References

See Also

Other Reporting Functions: umxAPA(), umxFactorScores(), umxGetParameters(), umxParameters(), umx_aggregate(), umx

Examples

require(umx)
umx_time('stop') # alert user stop called when not yet started... 
umx_time('stop')
umx_time('start')
data(demoOneFactor)
latents  = c("G")
manifests = names(demoOneFactor)
myData = mxData(cov(demoOneFactor), type = "cov", numObs=500)
m1 = umxRAM("umx_time_example", data = myData,
	umxPath(from = latents, to = manifests),
	umxPath(var = manifests),
	umxPath(var = latents, fixedAt = 1)
)
umx_time(m1) # report time from mxModel
m2 = umxRun(m1)
umx_time(c(m1, m2)) # print comparison table
umx_time('stop') # report the time since timer last started, and restart
umx_time('stop') # report the time since timer was restarted.

umx

Structural Equation Modeling and Twin Modeling in R

v4.10.10
GPL-3
Authors
Timothy C. Bates [aut, cre] (<https://orcid.org/0000-0002-1153-9007>), Gillespie Nathan [wit], Michael Zakharin [wit], Brenton Wiernik [ctb], Joshua N. Pritikin [ctb], Michael C. Neale [ctb], Hermine Maes [ctb]
Initial release
2021-11-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.