Module: Benchmark

Defined in:
ext/benchmark_ext/benchmark_ext.c

Class Method Summary collapse

Class Method Details

.realtimeObject

realtime block -> Float

Returns the elapsed real time used to execute the given block.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'ext/benchmark_ext/benchmark_ext.c', line 31

VALUE bmm_realtime(VALUE obj)
{
  long t1, t2;

  if (!rb_block_given_p())
  {
    rb_raise(rb_eArgError, "A block must be provided.");
  }

  t1 = bm_timestamp();
  rb_yield(obj);
  t2 = bm_timestamp();
  return rb_float_new((double) (t2 - t1) / 1000000);
}

.timestampObject

timestamp -> Float

Returns the current UNIX timestamp, as a Float.



22
23
24
# File 'ext/benchmark_ext/benchmark_ext.c', line 22

VALUE bmm_timestamp(VALUE obj) {
  return rb_float_new((double) bm_timestamp() / 1000000);
}