[前][次][番号順一覧][スレッド一覧]

ruby-changes:30598

From: akr <ko1@a...>
Date: Sat, 24 Aug 2013 11:01:11 +0900 (JST)
Subject: [ruby-changes:30598] akr:r42677 (trunk): [DOC]

akr	2013-08-24 11:01:07 +0900 (Sat, 24 Aug 2013)

  New Revision: 42677

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42677

  Log:
    [DOC]

  Modified files:
    trunk/process.c
Index: process.c
===================================================================
--- process.c	(revision 42676)
+++ process.c	(revision 42677)
@@ -6836,6 +6836,9 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6836
  *
  *  Returns a time returned by POSIX clock_gettime() function.
  *
+ *    p Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ *    #=> 896053.968060096
+ *
  *  +clock_id+ specifies a kind of clock.
  *  It is specifed as a constant which begins with <code>Process::CLOCK_</code>
  *  such as Process::CLOCK_REALTIME and Process::CLOCK_MONOTONIC.
@@ -6872,26 +6875,29 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6875
  *
  *  Emulations for +CLOCK_REALTIME+:
  *  [:GETTIMEOFDAY_BASED_CLOCK_REALTIME]
- *    Use gettimeofday().
+ *    Use gettimeofday() defined by Single Unix Specification.
+ *    (SUSv4 obsoleted it, though.)
  *    The resolution is 1 micro second.
  *  [:TIME_BASED_CLOCK_REALTIME]
- *    Use time().
+ *    Use time() defined by ISO C.
  *    The resolution is 1 second.
  *
  *  Emulations for +CLOCK_MONOTONIC+:
- *  [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC] Use mach_absolute_time(), available on Darwin.
- * 					  The resolution is CPU dependent.
+ *  [:MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC]
+ *    Use mach_absolute_time(), available on Darwin.
+ *    The resolution is CPU dependent.
  *
  *  Emulations for +CLOCK_PROCESS_CPUTIME_ID+:
  *  [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID]
- *    Use getrusage() with RUSAGE_SELF.
- *    getrusage() is defined by Single Unix Specification.
- *    The result is addition of ru_utime and ru_stime.
+ *    Use getrusage() defined by Single Unix Specification.
+ *    getrusage() is used with RUSAGE_SELF to obtain the time only for
+ *    the calling process (excluding the time for child processes).
+ *    The result is addition of user time (ru_utime) and system time (ru_stime).
  *    The resolution is 1 micro second.
  *  [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID]
  *    Use times() defined by POSIX.
- *    The result is addition of tms_utime and tms_stime.
- *    tms_cutime and tms_cstime are ignored.
+ *    The result is addition of user time (tms_utime) and system time (tms_stime).
+ *    tms_cutime and tms_cstime are ignored to exclude the time for child processes.
  *    The resolution is the clock tick.
  *    "getconf CLK_TCK" command shows the clock ticks per second.
  *    (The clock ticks per second is defined by HZ macro in older systems.)
@@ -6903,6 +6909,7 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6909
  *    Single Unix Specification defines CLOCKS_PER_SEC is 1000000.
  *    Non-Unix systems may define it a different value, though.
  *    If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 micro second.
+ *    If clock_t is 32 bit and CLOCKS_PER_SEC is 1000000, it overflows for each 72 minutes.
  *
  *  If the given +clock_id+ is not supported, Errno::EINVAL is raised.
  *
@@ -6928,10 +6935,6 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6935
  *  But some systems count leap seconds and others doesn't.
  *  So the result can be interpreted differently across systems.
  *  Time.now is recommended over CLOCK_REALTIME.
- *
- *    p Process.clock_gettime(Process::CLOCK_MONOTONIC)
- *    #=> 896053.968060096
- *
  */
 VALUE
 rb_clock_gettime(int argc, VALUE *argv)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]