1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (getrusage_time): uses clock_gettime() with

CLOCK_PROCESS_CPUTIME_ID when available, which provides a 1ns
  precision on linux. [ruby-core:50495] [Bug #7500]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nari 2012-12-05 14:53:16 +00:00
parent 31e6f72c8e
commit ab012bda4a
2 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Wed Dec 5 23:50:23 2012 Narihiro Nakamura <authornari@gmail.com>
* gc.c (getrusage_time): uses clock_gettime() with
CLOCK_PROCESS_CPUTIME_ID when available, which provides a 1ns
precision on linux. [ruby-core:50495] [Bug #7500]
Wed Dec 5 22:46:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Dec 5 22:46:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm.c (rb_vm_make_proc): save the proc made from the given block so * vm.c (rb_vm_make_proc): save the proc made from the given block so

9
gc.c
View file

@ -3853,7 +3853,14 @@ static inline void gc_prof_set_heap_info(rb_objspace_t *, gc_profile_record *);
static double static double
getrusage_time(void) getrusage_time(void)
{ {
#ifdef RUSAGE_SELF #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
struct timespec ts;
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) {
return ts.tv_sec + ts.tv_nsec * 1e-9;
}
return 0.0;
#elif defined RUSAGE_SELF
struct rusage usage; struct rusage usage;
struct timeval time; struct timeval time;
getrusage(RUSAGE_SELF, &usage); getrusage(RUSAGE_SELF, &usage);