Skip to content

Commit

Permalink
return calls per line
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jan 18, 2013
1 parent aedb1a4 commit 95dd56d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 2 additions & 7 deletions ext/rblineprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ summarize_files(st_data_t key, st_data_t record, st_data_t arg)

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));
rb_ary_store(ary, i, rb_ary_new3(2, ULL2NUM(srcfile->lines[i].total_time), ULL2NUM(srcfile->lines[i].calls)));

rb_hash_aset(ret, rb_str_new2(srcfile->filename), ary);

Expand Down Expand Up @@ -321,12 +321,7 @@ lineprof(VALUE self, VALUE filename)
VALUE ary = Qnil;

if (rblineprof.source_filename) {
long i;
ary = rb_ary_new();
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);
summarize_files(Qnil, (st_data_t)&rblineprof.file, ret);
} else {
st_foreach(rblineprof.files, summarize_files, ret);
}
Expand Down
7 changes: 4 additions & 3 deletions test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def outer
end

File.readlines(__FILE__).each_with_index do |line, num|
if (sample = profile[__FILE__][num+1]) > 0
printf "% 8.1fms | %s", sample/1000.0, line
time, calls = profile[__FILE__][num+1]
if calls && calls > 0
printf "% 8.1fms (% 5d) | %s", time/1000.0, calls, line
else
printf " | %s", line
printf " | %s", line
end
end

0 comments on commit 95dd56d

Please sign in to comment.