Sha256: 2141a7783eef09176372a6f40a435085de76d2224c4844358a391287c230eca8

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

/* Copyright (C) 2005-2011 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 cMeasureWallTime;

static double
measure_wall_time()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return (tv.tv_sec * 1000000 + tv.tv_usec) / 1000000.0;
}

prof_measurer_t* prof_measurer_wall_time()
{
  prof_measurer_t* measure = ALLOC(prof_measurer_t);
  measure->measure = measure_wall_time;
  return measure;
}

/* Document-method: prof_measure_wall_time
   call-seq:
     measure_wall_time -> float

Returns the wall time.*/
static VALUE
prof_measure_wall_time(VALUE self)
{
    return rb_float_new(measure_wall_time());
}

void rp_init_measure_wall_time()
{
    rb_define_const(mProf, "WALL_TIME", INT2NUM(MEASURE_WALL_TIME));
    rb_define_const(mProf, "WALL_TIME_ENABLED", Qtrue);

	cMeasureWallTime = rb_define_class_under(mMeasure, "WallTime", rb_cObject);
    rb_define_singleton_method(cMeasureWallTime, "measure", prof_measure_wall_time, 0);
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-prof-0.11.0.rc1-x86-mingw32 ext/ruby_prof/rp_measure_wall_time.c
ruby-prof-0.11.0.rc1 ext/ruby_prof/rp_measure_wall_time.c