Project

General

Profile

benchmark_methods.diff

Methods used in benchmark - tenderlovemaking (Aaron Patterson), 01/20/2018 02:50 AM

View differences:

iseq.c
324 324
    return iseq;
325 325
}
326 326

  
327
struct count_info {
328
    int count;
329
};
330

  
331
static void
332
count_markables(void *ctx, VALUE obj)
333
{
334
    struct count_info * my_count = (struct count_info *)ctx;
335
    my_count->count += 1;
336
}
337

  
338
static VALUE
339
iseqw_object_count(VALUE self)
340
{
341
    rb_iseq_t * iseq = iseqw_check(self);
342
    struct count_info my_count = {0,};
343
    rb_iseq_each_value(iseq, count_markables, &my_count);
344
    return INT2NUM(my_count.count);
345
}
346

  
347
static VALUE
348
iseqw_size(VALUE self)
349
{
350
    rb_iseq_t * iseq = iseqw_check(self);
351
    return INT2NUM(iseq->body->iseq_size);
352
}
353

  
327 354
VALUE
328 355
rb_iseq_pathobj_new(VALUE path, VALUE realpath)
329 356
{
......
3075 3102
    rb_define_method(rb_cISeq, "first_lineno", iseqw_first_lineno, 0);
3076 3103
    rb_define_method(rb_cISeq, "trace_points", iseqw_trace_points, 0);
3077 3104
    rb_define_method(rb_cISeq, "each_child", iseqw_each_child, 0);
3105
    rb_define_method(rb_cISeq, "markable_object_count", iseqw_object_count, 0);
3106
    rb_define_method(rb_cISeq, "size", iseqw_size, 0);
3078 3107

  
3079 3108
#if 0 /* TBD */
3080 3109
    rb_define_private_method(rb_cISeq, "marshal_dump", iseqw_marshal_dump, 0);