Skip to content

Commit

Permalink
exclusive timing
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jan 18, 2013
1 parent 5557581 commit aedb1a4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ext/rblineprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ typedef struct sourcefile {
long nlines;
sourceline_t *lines;

prof_time_t start;
prof_time_t total_time;
prof_time_t exclusive_start;
prof_time_t exclusive_time;
} sourcefile_t;

/*
Expand Down Expand Up @@ -180,10 +180,10 @@ profiler_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)

if (curr_srcfile != srcfile) {
if (curr_srcfile)
curr_srcfile->total_time += now - curr_srcfile->start;
curr_srcfile->exclusive_time += now - curr_srcfile->exclusive_start;

if (srcfile)
srcfile->start = now;
srcfile->exclusive_start = now;

rblineprof.curr_srcfile = srcfile;
}
Expand Down Expand Up @@ -264,7 +264,7 @@ summarize_files(st_data_t key, st_data_t record, st_data_t arg)
VALUE ary = rb_ary_new();
long i;

rb_ary_store(ary, 0, ULL2NUM(srcfile->total_time));
rb_ary_store(ary, 0, ULL2NUM(srcfile->exclusive_time));
for (i=1; i<srcfile->nlines; i++)
rb_ary_store(ary, i, ULL2NUM(srcfile->lines[i].total_time));

Expand Down Expand Up @@ -315,15 +315,15 @@ lineprof(VALUE self, VALUE filename)

sourcefile_t *curr_srcfile = rblineprof.curr_srcfile;
if (curr_srcfile)
curr_srcfile->total_time += timeofday_usec() - curr_srcfile->start;
curr_srcfile->exclusive_time += timeofday_usec() - curr_srcfile->exclusive_start;

VALUE ret = rb_hash_new();
VALUE ary = Qnil;

if (rblineprof.source_filename) {
long i;
ary = rb_ary_new();
rb_ary_store(ary, 0, ULL2NUM(rblineprof.file.total_time));
rb_ary_store(ary, 0, ULL2NUM(rblineprof.file.exclusive_time));
for (i=1; i<rblineprof.file.nlines; i++)
rb_ary_store(ary, i, ULL2NUM(rblineprof.file.lines[i].total_time));
rb_hash_aset(ret, rb_str_new2(rblineprof.source_filename), ary);
Expand Down

0 comments on commit aedb1a4

Please sign in to comment.