Analyzes the current R session to extract timing and memory usage information.
This function is particularly useful for understanding resource consumption
patterns and can be used with ga_footprint(runtime_h = "session")
.
The function uses base::proc.time()
to get CPU timing information
and base::gc()
to estimate memory usage when requested.
Arguments
- compute_mass_storage
Logical (default TRUE). Whether to compute memory usage statistics using the
base::gc()
function. Set to FALSE if you only need timing information.
Value
A list containing:
cpu_times_users
: User CPU time in secondscpu_times_system
: System CPU time in secondstime_elapsed
: Total elapsed time in secondscpu_times
: Combined user and system CPU timemass_storage_used
: Memory currently used (if requested)mass_storage_max
: Maximum memory used (if requested)
Examples
# Get complete session information
session_info <- session_runtime()
print(session_info)
#> $cpu_times_users
#> user.self
#> 8.744
#>
#> $cpu_times_system
#> user.child
#> 2.111
#>
#> $time_elapsed
#> elapsed
#> 15.778
#>
#> $cpu_times
#> user.self
#> 10.855
#>
#> $mass_storage_used
#> [1] 252.5
#>
#> $mass_storage_max
#> [1] 378.1
#>
# Get only timing information (faster)
timing_only <- session_runtime(compute_mass_storage = FALSE)
cat("Session has been running for", timing_only$time_elapsed, "seconds\n")
#> Session has been running for 16.233 seconds