- Version: 0.3-1
- License: BSD 2-Clause
- Project home: https://github.com/shinra-dev/merkhet
- Bug reports: https://github.com/shinra-dev/merkhet/issues
The name "merkhet" is an ancient word for a kind of timekeeping device, which means the "instrument of knowing." The package contains several timing utilities useful for benchmarking and performance monitoring.
You can install the stable version from the HPCRAN using the usual install.packages()
:
install.packages("merkhet", repos="https://hpcran.org")
The development version is maintained on GitHub:
remotes::install_github("shinra-dev/merkhet")
System uptime:
Sys.uptime()
# 1.853 days
There are also some utilities for seeing how long the current R process has been running (by the various standard measures):
Sys.runtime()
# 10 seconds
Sys.usrtime()
# 0.39 seconds
Sys.systime()
# 0.38 seconds
These three utilities combined allow you to do something akin to a post-hoc system.time()
:
post.system.time()
# user system elapsed
# 0.42 0.38 17.00
The wc.time()
function is a simple wrapper around system.time()
to measure the wallclock time with the output in a hunman-readable time:
wc.time(1+1)
# 0 seconds
wc.time(Sys.sleep(12.34567))
# 12.351 seconds
wc.time(Sys.sleep(123.4567))
# 2.059 minutes
You can also take a time and convert it to a human-readable time using readable.time()
readable.time(500)
## 8.333 minutes
readable.time(5000)
## 1.389 hours
readable.time(50000)
## 13.889 hours
readable.time(500000)
## 5.787 days
The package also includes a simple benchmarking wrapper around system.time()
. It uses an R6 class so you can add timed expressions iteratively, each with different numbers of replications.
library(merkhet)
b = bench()
b$time(Sys.sleep(.3), reps=2)
b
## ## Benchmark of 1 operations
## elapsed reps avg relative
## Sys.sleep(0.3) 0.6 2 0.3 1
b$time(Sys.sleep(.5))
b
## ## Benchmark of 2 operations
## elapsed reps avg relative
## Sys.sleep(0.3) 0.6 2 0.3 1.2
## Sys.sleep(0.5) 0.5 1 0.5 1.0
There is also an option to dump the data to csv (file or stdout):
b$csv()
## expr,elapsed,reps,avg,relative
## "Sys.sleep(0.3)",0.6,2,0.3,1.2
## "Sys.sleep(0.5)",0.5,1,0.5,1
as well as make simple boxplots
b$plot()