Created
March 28, 2011 02:22
-
-
Save goncalossilva/889893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 5e048a2952661a975814b3f89c679c22f5b702ed Mon Sep 17 00:00:00 2001 | |
| From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= <goncalossilva@gmail.com> | |
| Date: Thu, 24 Mar 2011 21:29:02 +0000 | |
| Subject: [PATCH] measure object allocations when rb_gc_malloc_allocations is available | |
| --- | |
| ext/ruby_prof/measure_allocations.h | 25 +++++++++++++++++++++++++ | |
| 1 files changed, 25 insertions(+), 0 deletions(-) | |
| diff --git a/ext/ruby_prof/measure_allocations.h b/ext/ruby_prof/measure_allocations.h | |
| index 3dc9701..a8846e8 100644 | |
| --- a/ext/ruby_prof/measure_allocations.h | |
| +++ b/ext/ruby_prof/measure_allocations.h | |
| @@ -55,4 +55,29 @@ prof_measure_allocations(VALUE self) | |
| return ULONG2NUM(rb_os_allocated_objects()); | |
| #endif | |
| } | |
| + | |
| +#elif defined(HAVE_RB_GC_MALLOC_ALLOCATIONS) | |
| +#define MEASURE_ALLOCATIONS 3 | |
| + | |
| +static prof_measure_t | |
| +measure_allocations() | |
| +{ | |
| + return rb_gc_malloc_allocations(); | |
| +} | |
| + | |
| +static double | |
| +convert_allocations(prof_measure_t c) | |
| +{ | |
| + return c; | |
| +} | |
| + | |
| +static VALUE | |
| +prof_measure_allocations(VALUE self) | |
| +{ | |
| +#if defined(HAVE_LONG_LONG) | |
| + return ULL2NUM(rb_os_allocated_objects()); | |
| +#else | |
| + return ULONG2NUM(rb_os_allocated_objects()); | |
| +#endif | |
| +} | |
| #endif | |
| -- | |
| 1.7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment