From: Philippe E. <ph...@wa...> - 2003-04-06 16:39:37
|
John Levon wrote: > With this patch, you get : > > static void opd_put_sample(struct opd_image * image, int in_kernel, > char const * buffer, size_t index) > { /* opd_put_sample 43282 6.697% 104865 10.84%, prolog 9691 1.499% 16487 1.704% */ hum I never see samples going on the same line as symbol, annoying ... > vma_t eip = get_buffer_value(buffer, index); /* 5088 0.7872% 7361 0.7609% */ > unsigned long event = get_buffer_value(buffer, index + 1); /* 6760 1.046% 10055 1.039% */ > > opd_stats[OPD_SAMPLES]++; /* 2763 0.4275% 3798 0.3926% */ > > if (in_kernel > 0) { /* 2993 0.4631% 10236 1.058% */ > struct opd_image * app_image = 0; /* 669 0.1035% 2293 0.237% */ > > > Not particularly pretty, but I think maintaining line numbers is worth it. yes > > Note the assumption regarding the address of prolog samples. Phil, > does this make sense ? It's certainly the case with my version of gcc etc. you can't assume there is sample at the same location as a symbol, you will get, depending on gcc version: /* opd_put_sample 43282 6.697% 104865 10.84%, prolog */ which is confusing, it's easy to cure by small modification of your code, output ", prolog" only if we get a symbol on this line and samples too. I'm unsure if prolog is an accurate string > > The pp_interface talks about prefixing source lines instead. It's certainly possible, > but somewhat difficult (i.e. slow) to get things lined up. And it will push uh, how you know it will slow ? I think we must do a compromise: accept to misalign for symbol but align all the other. > all lines past the reasonable line length, instead of just the sample ones. So I think > I actually prefer the above. I don't think so, if user profile a program he is interested first by profiling result, they must go to the begin of line. /* 3 0.4% */ /* 4300 98.7% */ with this format you see quickly where you must focus your attention, if samples go to right it will be hard for user to focus to point where they are hot spot. If user get problem with line length it can open the original source in another window and look at it, isn't it the point to maintain line number ? > Index: op_to_source.cpp > @@ -691,20 +691,19 @@ void do_output_one_file(ostream & out, i > counter_array_t count; > samples->samples_count(count, filename); > > - if (header) > + if (header) { > output_per_file_info(out, filename, count); > + out << line0_info(filename) << endl; > + } humm annoying if we want to maintain line number we must output line0 info at end of file. We must live with that... > -void output_one_counter(ostream & out, size_t counter, size_t total) > +string const counter_str(size_t counter, size_t total) > { > - out << " "; > - out << counter << " "; > - out << setprecision(4) << (op_ratio(counter, total) * 100.0) << "%"; > + string str = tostr(counter) + " "; > + ostringstream os; > + os << setprecision(4) << (op_ratio(counter, total) * 100.0) << "%"; > + str += os.str(); > + return str; > } what about using snprintf to get a strict width format, I've not already solved the problem to get strict width formatting for floating point with iostream ... > +string const line0_info(string const & filename) indeed! regards, Phil |