Sha256: 2401844a2c938b73ba7b4ae6ccf6ca816e36083c5611031df920ec109c6509e5

Contents?: true

Size: 1.38 KB

Versions: 18

Compression:

Stored size: 1.38 KB

Contents

/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
   Please see the LICENSE file for copyright and distribution information */

/* :nodoc: */

#include "ruby_prof.h"

static VALUE cMeasureGcTimes;

#if defined(HAVE_RB_GC_TIME)
  VALUE rb_gc_time();
#endif

static double
measure_gc_time()
{
#if defined(HAVE_RB_GC_TOTAL_TIME)
#define MEASURE_GC_TIME_ENABLED Qtrue
    return rb_gc_total_time();

#elif defined(HAVE_RB_GC_TIME)
#define MEASURE_GC_TIME_ENABLED Qtrue
    const double conversion = 1000000.0;
#if HAVE_LONG_LONG
    return NUM2LL(rb_gc_time()) / conversion;
#else
    return NUM2LONG(rb_gc_time()) / conversion;
#endif

#else
#define MEASURE_GC_TIME_ENABLED Qfalse
    return 0.0;
#endif
}

prof_measurer_t* prof_measurer_gc_time()
{
  prof_measurer_t* measure = ALLOC(prof_measurer_t);
  measure->measure = measure_gc_time;
  return measure;
}

/* call-seq:
   measure -> float

Returns the time spent performing GC.*/
static VALUE
prof_measure_gc_time(VALUE self)
{
    return rb_float_new(measure_gc_time());
}

void rp_init_measure_gc_time()
{
    rb_define_const(mProf, "GC_TIME", INT2NUM(MEASURE_GC_TIME));
    rb_define_const(mProf, "GC_TIME_ENABLED", MEASURE_GC_TIME_ENABLED);

    cMeasureGcTimes = rb_define_class_under(mMeasure, "GcTime", rb_cObject);
    rb_define_singleton_method(cMeasureGcTimes, "measure", prof_measure_gc_time, 0);
}

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
ruby-prof-0.17.0 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.16.2 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.16.1 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.16.0 ext/ruby_prof/rp_measure_gc_time.c
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/ruby-prof-0.15.9/ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.9 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.8 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.7 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.6 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.5 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.4 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.3 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.2 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.1 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.15.0 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.14.2 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.14.1 ext/ruby_prof/rp_measure_gc_time.c
ruby-prof-0.14.0 ext/ruby_prof/rp_measure_gc_time.c