developer tip

R system.time (exp) 출력에서 ​​측정하는 '사용자'및 '시스템'시간은 무엇입니까?

copycodes 2020. 9. 19. 11:30
반응형

R system.time (exp) 출력에서 ​​측정하는 '사용자'및 '시스템'시간은 무엇입니까?


system.time(expression)R 함수의 실행 시간을 측정 하는 사용 하고 있습니다.

호출에 대한 출력

system.time(myfunction())

is :

    user  system elapsed   
  117.36    5.65  127.86

'사용자'와 '시스템'은 무엇을 측정합니까?


이것은 ?proc.time( system.time()클래스의 객체를 반환) 에서 논의됩니다 "proc.time".

Details:

     ‘proc.time’ returns five elements for backwards compatibility, but
     its ‘print’ method prints a named vector of length 3.  The first
     two entries are the total user and system CPU times of the current
     R process and any child processes on which it has waited, and the
     third entry is the ‘real’ elapsed time since the process was
     started.

....과

Value:

....

     The definition of ‘user’ and ‘system’ times is from your OS.
     Typically it is something like

     _The ‘user time’ is the CPU time charged for the execution of user
     instructions of the calling process. The ‘system time’ is the CPU
     time charged for execution by the system on behalf of the calling
     process._

분명한 설명은 내가 이제까지의 차이에 읽은 usersystem경과 시간에 의해 제공되었다 [R-도움말]에 윌리엄 던랩 :

"사용자 CPU 시간"은 현재 프로세스 (즉, 현재 R 세션)에서 소비 한 CPU 시간을 제공하고 "시스템 CPU 시간"은 현재 프로세스 대신 커널 (운영 체제)에서 소비 한 CPU 시간을 제공합니다. 운영 체제는 파일 열기, 입력 또는 출력 수행, 다른 프로세스 시작 및 시스템 시계보기 (많은 프로세스가 공유해야하는 리소스를 포함하는 작업)와 같은 작업에 사용됩니다.

?proc.time비슷한 것을 반환 하지만 이 설명은 저에게 훨씬 더 이해하기 쉬웠습니다.


어쨌든 위키 백과에서 일반적이기 때문에 :

'사용자 CPU 시간'이라는 용어는 처음에는 약간 오해의 소지가 있습니다. 명확하게 말하면, 총 시간 (실제 CPU 시간)은 CPU가 프로그램에 대해 일부 작업을 수행하는 데 소비하는 시간과 CPU가 프로그램을 대신하여 커널에 대한 시스템 호출을 수행하는 데 소비하는 시간의 조합입니다. 프로그램이 배열을 반복 할 때 사용자 CPU 시간이 누적됩니다. 반대로 프로그램이 exec 또는 fork와 같은 시스템 호출을 실행하면 시스템 CPU 시간이 누적됩니다.

http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time


다음은 몇 가지 간단한 설명입니다.

경과 시간 은 표현식에 대해 CPU에 청구 된 시간 입니다.

사용자 시간 은 벽시계 시간입니다. 사용자로서 경험 한 시간.

Usually both times are relatively close. But they may vary in some other situations. For example:

  • If elapsed time > user time, this means that the CPU is waiting around for some other operations (may be external) to be done.
  • If elapsed time < user time, this means that your machine has multiple cores and is able to use them

Since those time variables are defined by your OS, you can retrieve information on how they are calculated by executing man time in your shell (on Unix):

...These statistics consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2)), and (iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)).

The definition of the mentioned time variables can be found here:

tms_utime User CPU time.

tms_stime System CPU time.

tms_cutime User CPU time of terminated child processes.

tms_cstime System CPU time of terminated child processes.

A a clarification of the differences between user and system time is described in daroczig's answer and elsewhere on SO:

The tms_utime element is the amount of time spent executing your code, or the code in the C library. The tms_stime element is the amount of time spent in the kernel executing code on your behalf.

참고URL : https://stackoverflow.com/questions/5688949/what-are-user-and-system-times-measuring-in-r-system-timeexp-output

반응형