U:RDoc::AnyMethod[iI"clock_gettime:ETI"Process::clock_gettime;TT:publico:RDoc::Markup::Document:@parts[#o:RDoc::Markup::Paragraph; [I"?Returns a time returned by POSIX clock_gettime() function.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"7p Process.clock_gettime(Process::CLOCK_MONOTONIC)
;TI"#=> 896053.968060096
;T:@format0o;
; [I"++clock_id+ specifies a kind of clock. ;TI"RIt is specified as a constant which begins with Process::CLOCK_
;TI"Bsuch as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC.;T@o;
; [I"8The supported constants depends on OS and version. ;TI">Ruby provides following types of +clock_id+ if available.;T@o:RDoc::Markup::List:
@type:
LABEL:@items[o:RDoc::Markup::ListItem:@label[I"CLOCK_REALTIME;T; [o;
; [I"PSUSv2 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 2.1, macOS 10.12;To;;[I"CLOCK_MONOTONIC;T; [o;
; [I"PSUSv3 to 4, Linux 2.5.63, FreeBSD 3.0, NetBSD 2.0, OpenBSD 3.4, macOS 10.12;To;;[I"CLOCK_PROCESS_CPUTIME_ID;T; [o;
; [I"7SUSv3 to 4, Linux 2.5.63, OpenBSD 5.4, macOS 10.12;To;;[I"CLOCK_THREAD_CPUTIME_ID;T; [o;
; [I"DSUSv3 to 4, Linux 2.5.63, FreeBSD 7.1, OpenBSD 5.4, macOS 10.12;To;;[I"CLOCK_VIRTUAL;T; [o;
; [I"FreeBSD 3.0, OpenBSD 2.1;To;;[I"CLOCK_PROF;T; [o;
; [I"FreeBSD 3.0, OpenBSD 2.1;To;;[I"CLOCK_REALTIME_FAST;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_REALTIME_PRECISE;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_REALTIME_COARSE;T; [o;
; [I"Linux 2.6.32;To;;[I"CLOCK_REALTIME_ALARM;T; [o;
; [I"Linux 3.0;To;;[I"CLOCK_MONOTONIC_FAST;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_MONOTONIC_PRECISE;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_MONOTONIC_COARSE;T; [o;
; [I"Linux 2.6.32;To;;[I"CLOCK_MONOTONIC_RAW;T; [o;
; [I"Linux 2.6.28, macOS 10.12;To;;[I"CLOCK_MONOTONIC_RAW_APPROX;T; [o;
; [I"macOS 10.12;To;;[I"CLOCK_BOOTTIME;T; [o;
; [I"Linux 2.6.39;To;;[I"CLOCK_BOOTTIME_ALARM;T; [o;
; [I"Linux 3.0;To;;[I"CLOCK_UPTIME;T; [o;
; [I"FreeBSD 7.0, OpenBSD 5.5;To;;[I"CLOCK_UPTIME_FAST;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_UPTIME_RAW;T; [o;
; [I"macOS 10.12;To;;[I"CLOCK_UPTIME_RAW_APPROX;T; [o;
; [I"macOS 10.12;To;;[I"CLOCK_UPTIME_PRECISE;T; [o;
; [I"FreeBSD 8.1;To;;[I"CLOCK_SECOND;T; [o;
; [I"FreeBSD 8.1;T@o;
; [ I"9Note that SUS stands for Single Unix Specification. ;TI"HSUS contains POSIX and clock_gettime is defined in the POSIX part. ;TI".SUS defines CLOCK_REALTIME mandatory but ;TI"XCLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are optional.;T@o;
; [I"7Also, several symbols are accepted as +clock_id+. ;TI".There are emulations for clock_gettime().;T@o;
; [I"8For example, Process::CLOCK_REALTIME is defined as ;TI"P+:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available.;T@o;
; [I"%Emulations for +CLOCK_REALTIME+:;To;;;;[o;;[I"':GETTIMEOFDAY_BASED_CLOCK_REALTIME;T; [o;
; [I"(Use gettimeofday() defined by SUS. ;TI"#(SUSv4 obsoleted it, though.) ;TI"%The resolution is 1 microsecond.;To;;[I":TIME_BASED_CLOCK_REALTIME;T; [o;
; [I""Use time() defined by ISO C. ;TI" The resolution is 1 second.;T@o;
; [I"&Emulations for +CLOCK_MONOTONIC+:;To;;;;[o;;[I".:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;T; [o;
; [I"4Use mach_absolute_time(), available on Darwin. ;TI"%The resolution is CPU dependent.;To;;[I"!:TIMES_BASED_CLOCK_MONOTONIC;T; [o;
; [I"7Use the result value of times() defined by POSIX. ;TI"œPOSIX defines it as "times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time)". ;TI"RFor example, GNU/Linux returns a value based on jiffies and it is monotonic. ;TI"BHowever, 4.4BSD uses gettimeofday() and it is not monotonic. ;TI"D(FreeBSD uses clock_gettime(CLOCK_MONOTONIC) instead, though.) ;TI"'The resolution is the clock tick. ;TI"A"getconf CLK_TCK" command shows the clock ticks per second. ;TI"K(The clock ticks per second is defined by HZ macro in older systems.) ;TI"\If it is 100 and clock_t is 32 bits integer type, the resolution is 10 millisecond and ;TI"$cannot represent over 497 days.;T@o;
; [I"/Emulations for +CLOCK_PROCESS_CPUTIME_ID+:;To;;;;[o;;[I".:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID;T; [o;
; [
I"%Use getrusage() defined by SUS. ;TI"Fgetrusage() is used with RUSAGE_SELF to obtain the time only for ;TI"Cthe calling process (excluding the time for child processes). ;TI"PThe result is addition of user time (ru_utime) and system time (ru_stime). ;TI"%The resolution is 1 microsecond.;To;;[I"*:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID;T; [o;
; [I"#Use times() defined by POSIX. ;TI"RThe result is addition of user time (tms_utime) and system time (tms_stime). ;TI"Ttms_cutime and tms_cstime are ignored to exclude the time for child processes. ;TI"'The resolution is the clock tick. ;TI"A"getconf CLK_TCK" command shows the clock ticks per second. ;TI"K(The clock ticks per second is defined by HZ macro in older systems.) ;TI"4If it is 100, the resolution is 10 millisecond.;To;;[I"*:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID;T; [o;
; [I"#Use clock() defined by ISO C. ;TI")The resolution is 1/CLOCKS_PER_SEC. ;TI" number
;T0[ I"(*args);T@oFI"Process;TcRDoc::NormalModule00