Module: StackProf

Defined in:
lib/stackprof/report.rb,
ext/stackprof.c

Defined Under Namespace

Classes: Report

Class Method Summary collapse

Class Method Details

.run(type, usec) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'ext/stackprof.c', line 169

static VALUE
stackprof_run(VALUE self, VALUE type, VALUE usec)
{
    VALUE results, frames;
    rb_need_block();
    if (!_results.frames)
  _results.frames = st_init_numtable();
    _results.overall_samples = 0;

    stackprof_start(self, type, usec);
    rb_yield(Qundef);
    stackprof_stop(self);

    results = rb_hash_new();
    rb_hash_aset(results, sym_version, DBL2NUM(1.0));
    rb_hash_aset(results, sym_mode, rb_sprintf("%"PRIsVALUE"(%"PRIsVALUE")", type, usec));
    rb_hash_aset(results, sym_samples, SIZET2NUM(_results.overall_samples));

    frames = rb_hash_new();
    rb_hash_aset(results, sym_frames, frames);
    st_foreach(_results.frames, frame_i, (st_data_t)frames);

    return results;
}