Class: RubyProf::Allocation

Inherits:
Object
  • Object
show all
Defined in:
ext/ruby_prof/rp_allocation.c

Instance Method Summary collapse

Instance Method Details

#_dump_dataObject

:nodoc:



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'ext/ruby_prof/rp_allocation.c', line 294

static VALUE prof_allocation_dump(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);

    VALUE result = rb_hash_new();

    rb_hash_aset(result, ID2SYM(rb_intern("key")), ULL2NUM(allocation->key));
    rb_hash_aset(result, ID2SYM(rb_intern("klass_name")), prof_allocation_klass_name(self));
    rb_hash_aset(result, ID2SYM(rb_intern("klass_flags")), INT2FIX(allocation->klass_flags));
    rb_hash_aset(result, ID2SYM(rb_intern("source_file")), allocation->source_file);
    rb_hash_aset(result, ID2SYM(rb_intern("source_line")), INT2FIX(allocation->source_line));
    rb_hash_aset(result, ID2SYM(rb_intern("count")), INT2FIX(allocation->count));
    rb_hash_aset(result, ID2SYM(rb_intern("memory")), ULL2NUM(allocation->memory));

    return result;
}

#_load_data(data) ⇒ Object

:nodoc:



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'ext/ruby_prof/rp_allocation.c', line 312

static VALUE prof_allocation_load(VALUE self, VALUE data)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    allocation->object = self;

    allocation->key = RB_NUM2ULL(rb_hash_aref(data, ID2SYM(rb_intern("key"))));
    allocation->klass_name = rb_hash_aref(data, ID2SYM(rb_intern("klass_name")));
    allocation->klass_flags = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("klass_flags"))));
    allocation->source_file = rb_hash_aref(data, ID2SYM(rb_intern("source_file")));
    allocation->source_line = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("source_line"))));
    allocation->count = FIX2INT(rb_hash_aref(data, ID2SYM(rb_intern("count"))));
    allocation->memory = NUM2ULONG(rb_hash_aref(data, ID2SYM(rb_intern("memory"))));

    return data;
}

#countNumeric

Returns the number of times this class has been allocated.

Returns:

  • (Numeric)


277
278
279
280
281
# File 'ext/ruby_prof/rp_allocation.c', line 277

static VALUE prof_allocation_count(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    return INT2FIX(allocation->count);
}

#klass_flagsInteger

Returns the klass flags

Returns:

  • (Integer)


247
248
249
250
251
# File 'ext/ruby_prof/rp_allocation.c', line 247

static VALUE prof_allocation_klass_flags(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    return INT2FIX(allocation->klass_flags);
}

#klassClass

Returns the type of Class being allocated.

Returns:

  • (Class)


232
233
234
235
236
237
238
239
240
# File 'ext/ruby_prof/rp_allocation.c', line 232

static VALUE prof_allocation_klass_name(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);

    if (allocation->klass_name == Qnil)
        allocation->klass_name = resolve_klass_name(allocation->klass, &allocation->klass_flags);

    return allocation->klass_name;
}

#lineNumeric

Returns the the line number where objects were allocated.

Returns:

  • (Numeric)


267
268
269
270
271
# File 'ext/ruby_prof/rp_allocation.c', line 267

static VALUE prof_allocation_source_line(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    return INT2FIX(allocation->source_line);
}

#memoryNumeric

Returns the amount of memory allocated.

Returns:

  • (Numeric)


287
288
289
290
291
# File 'ext/ruby_prof/rp_allocation.c', line 287

static VALUE prof_allocation_memory(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    return ULL2NUM(allocation->memory);
}

#source_fileString

Returns the the line number where objects were allocated.

Returns:

  • (String)


257
258
259
260
261
# File 'ext/ruby_prof/rp_allocation.c', line 257

static VALUE prof_allocation_source_file(VALUE self)
{
    prof_allocation_t* allocation = prof_allocation_get(self);
    return allocation->source_file;
}