https://github.com/poissonconsulting/hmstimer
An R package to track elapsed clock time using a `hms::hms()` scalar.
https://github.com/poissonconsulting/hmstimer
cran hms r rstats timer
Last synced: 30 days ago
JSON representation
An R package to track elapsed clock time using a `hms::hms()` scalar.
- Host: GitHub
- URL: https://github.com/poissonconsulting/hmstimer
- Owner: poissonconsulting
- License: other
- Created: 2019-05-10T19:38:48.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-21T17:19:36.000Z (3 months ago)
- Last Synced: 2025-02-27T05:12:12.866Z (about 2 months ago)
- Topics: cran, hms, r, rstats, timer
- Language: R
- Homepage: https://poissonconsulting.github.io/hmstimer/
- Size: 2.2 MB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- jimsghstars - poissonconsulting/hmstimer - An R package to track elapsed clock time using a `hms::hms()` scalar. (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# hmstimer
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/poissonconsulting/hmstimer/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/poissonconsulting/hmstimer)
[](https://opensource.org/license/mit/)
[](https://cran.r-project.org/package=hmstimer)
`hmstimer` is an R package to
track elapsed clock time using a [hms::hms](https://github.com/tidyverse/hms) scalar.`hmstimer` was originally developed to time Bayesian model runs. It should not be used to estimate how long extremely fast code takes to execute as the package code adds a small time cost.
Create and start a timer with `tmr_timer(start = TRUE)`.
```{r}
library(hmstimer)tmr <- tmr_timer(start = TRUE)
Sys.sleep(0.1)
str(tmr)
hms::as_hms(tmr)
```Get the elapsed time with `tmr_elapsed()`.
The title is optional.
```{r}
tmr <- tmr_timer(start = TRUE, title = "my timer")Sys.sleep(0.1)
tmr_elapsed(tmr)Sys.sleep(0.1)
tmr_elapsed(tmr)
```Stop the timer with `tmr_stop()`.
```{r}
tmr <- tmr_stop(tmr)
tmr_elapsed(tmr)Sys.sleep(1)
tmr_elapsed(tmr)
```Restart the timer with `tmr_start()`.
```{r}
tmr <- tmr_start(tmr)
tmr_elapsed(tmr)
Sys.sleep(0.1)
tmr_elapsed(tmr)
```There are several options for printing and formatting including coercing to a hms object.
```{r}
tmr <- tmr_stop(tmr)
print(tmr)
tmr_print(tmr)
tmr_format(tmr, digits = 5)
```If running `tmr_print()` behaves differently.
```{r}
tmr <- tmr_start(tmr)
tmr_print(tmr)
```The time for a block of code to complete can be printed using `with_timer()`.
```{r}
with_timer({
Sys.sleep(0.1)
Sys.sleep(0.1)
1 + 1
})
```## Installation
### Release
To install the release version from [CRAN](https://CRAN.R-project.org/package=hmstimer).
```r
install.packages("hmstimer")
```The website for the release version is at .
### Development
To install the development version from [GitHub](https://github.com/poissonconsulting/hmstimer)
```r
# install.packages("remotes")
remotes::install_github("poissonconsulting/hmstimer")
```or from [r-universe](https://poissonconsulting.r-universe.dev/hmstimer).
```r
install.packages("hmstimer", repos = c("https://poissonconsulting.r-universe.dev", "https://cloud.r-project.org"))
```## Contribution
Please report any [issues](https://github.com/poissonconsulting/hmstimer/issues).
[Pull requests](https://github.com/poissonconsulting/hmstimer/pulls) are always welcome.
## Code of Conduct
Please note that the hmstimer project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.