ID EN
System & OS

system.time

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Kembalikan waktu CPU (dan lainnya) yang digunakan expr.

Syntax

R
system.time(expr, gcFirst = TRUE)
<!-- %Deprecated unix.time(expr, gcFirst = TRUE) -->

Arguments

Parameter Deskripsi
expr Valid R expression to be timed.
gcFirst Logical - should a garbage collection be performed immediately before the timing? Default is TRUE.

Return Value

Objek kelas "proc_time": lihat proc.time untuk detailnya.

Details

system.time memanggil fungsi proc.time, mengevaluasi expr, dan kemudian memanggil proc.time sekali lagi, mengembalikan selisih antara dua panggilan proc.time. unix.time telah menjadi alias dari system.time, untuk kompatibilitas dengan S, dan akhirnya tidak digunakan lagi pada tahun 2016. Waktu evaluasi ekspresi yang sama dapat sangat bervariasi tergantung pada apakah evaluasi tersebut memicu pengumpulan sampah. Ketika gcFirst bernilai TRUE, pengumpulan sampah (gc) akan dilakukan segera sebelum evaluasi expr. Hal ini biasanya akan menghasilkan pengaturan waktu yang lebih konsisten.

Contoh

Example
R
# NOT RUN {
require(stats)
# }
# NOT RUN {
system.time(for(i in 1:100) mad(runif(1000)))
# }
# NOT RUN {
exT <- function(n = 10000) {
  # Purpose: Test if system.time works ok;   n: loop size
  system.time(for(i in 1:n) x <- mean(rt(1000, df = 4)))
}
#-- Try to interrupt one of the following (using Ctrl-C / Escape):
exT()                 #- about 4 secs on a 2.5GHz Xeon
system.time(exT())    #~ +/- same
# }

See Also

proc.time time which is for time series. Sys.time to get the current date & time.