From: Philippe E. <ph...@us...> - 2002-10-04 03:29:21
|
Update of /cvsroot/oprofile/oprofile/pp In directory usw-pr-cvs1:/tmp/cvs-serv9159/pp Modified Files: op_time_options.cpp opp_symbol.cpp opp_symbol.h outsymbflag.h Log Message: implement 'q4 'Q' output format flags fix #618165 regards, Phil Index: op_time_options.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/op_time_options.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- op_time_options.cpp 1 Oct 2002 22:32:31 -0000 1.17 +++ op_time_options.cpp 4 Oct 2002 03:29:18 -0000 1.18 @@ -151,7 +151,8 @@ outsymbflag fl = output_symbol::ParseOutputOption(output_format); - if (fl == osf_none || (fl & ~(osf_header|osf_details)) == 0) { + if (fl == osf_none || (fl & ~(osf_header|osf_details)) == 0 || + (fl & (osf_percent_details | osf_percent_cumulated_details))) { cerr << "op_time: invalid --output-format flags.\n"; output_symbol::ShowHelp(); exit(EXIT_FAILURE); Index: opp_symbol.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opp_symbol.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- opp_symbol.cpp 1 Oct 2002 22:32:31 -0000 1.30 +++ opp_symbol.cpp 4 Oct 2002 03:29:18 -0000 1.31 @@ -36,6 +36,8 @@ { 'S', osf_nr_samples_cumulated, "nr cumulated samples" }, { 'p', osf_percent, "nr percent samples" }, { 'P', osf_percent_cumulated, "nr cumulated percent samples" }, + { 'q', osf_percent_details, "nr percent samples details" }, + { 'Q', osf_percent_cumulated_details, "nr cumulated percent samples details" }, { 'n', osf_symb_name, "symbol name" }, { 'l', osf_linenr_info, "source file name and line nr" }, { 'L', osf_short_linenr_info, "base name of source file and line nr" }, @@ -118,6 +120,14 @@ &output_symbol::format_image_name }, { osf_short_image_name, 16, "image name", &output_symbol::format_short_image_name }, + { osf_percent, 12, + "%-age", &output_symbol::format_percent }, + { osf_percent_cumulated, 10, + "cum %-age", &output_symbol::format_cumulated_percent }, + { osf_percent_details, 12, + "%-age", &output_symbol::format_percent_details }, + { osf_percent_cumulated_details, 10, + "cum %-age", &output_symbol::format_cumulated_percent_details }, }; size_t const nr_field_descr = sizeof(field_descr) / sizeof(field_descr[0]); @@ -132,8 +142,10 @@ { for (size_t i = 0 ; i < samples_container.get_nr_counters() ; ++i) { total_count[i] = samples_container.samples_count(i); + total_count_details[i] = samples_container.samples_count(i); cumulated_samples[i] = 0; cumulated_percent[i] = 0; + cumulated_percent_details[i] = 0; } } @@ -213,6 +225,7 @@ temp_cumulated_percent[i] = cumulated_percent[i]; total_count[i] = symb->sample.counter[i]; + cumulated_percent_details[i] -= symb->sample.counter[i]; cumulated_samples[i] = 0; cumulated_percent[i] = 0; } @@ -452,6 +465,37 @@ double ratio = total_count[ctr] ? double(cumulated_percent[ctr]) / total_count[ctr] + : 0.0; + + out << ratio * 100.0; + + return out.str(); +} + +string output_symbol::format_percent_details(string const &, + sample_entry const & sample, size_t ctr) +{ + ostringstream out; + + double ratio = total_count_details[ctr] + ? double(sample.counter[ctr]) / total_count_details[ctr] + : 0.0; + + out << ratio * 100.0; + + return out.str(); +} + +string output_symbol::format_cumulated_percent_details(string const &, + sample_entry const & sample, + size_t ctr) +{ + ostringstream out; + + cumulated_percent_details[ctr] += sample.counter[ctr]; + + double ratio = total_count_details[ctr] + ? double(cumulated_percent_details[ctr]) / total_count_details[ctr] : 0.0; out << ratio * 100.0; Index: opp_symbol.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/opp_symbol.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- opp_symbol.h 7 Sep 2002 18:19:40 -0000 1.26 +++ opp_symbol.h 4 Oct 2002 03:29:18 -0000 1.27 @@ -123,6 +123,11 @@ std::string format_cumulated_percent(std::string const & name, sample_entry const & sample, size_t); + std::string format_percent_details(std::string const & name, + sample_entry const & sample, size_t); + std::string format_cumulated_percent_details(std::string const & name, + sample_entry const & sample, + size_t); //@} private: void DoOutput(std::ostream & out, std::string const & name, @@ -143,6 +148,8 @@ u32 total_count[OP_MAX_COUNTERS]; u32 cumulated_samples[OP_MAX_COUNTERS]; u32 cumulated_percent[OP_MAX_COUNTERS]; + u32 total_count_details[OP_MAX_COUNTERS]; + u32 cumulated_percent_details[OP_MAX_COUNTERS]; int counter; bool first_output; }; Index: outsymbflag.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/outsymbflag.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- outsymbflag.h 7 Sep 2002 18:19:40 -0000 1.5 +++ outsymbflag.h 4 Oct 2002 03:29:18 -0000 1.6 @@ -22,31 +22,39 @@ * of field */ enum outsymbflag { - osf_none = 0, - osf_vma = 1 << 0, - /// this four field can be repeated on output for each counter. - osf_nr_samples = 1 << 1, - osf_nr_samples_cumulated = 1 << 2, - osf_percent = 1 << 3, - osf_percent_cumulated = 1 << 4, - /// used internally - osf_repeat_mask = osf_nr_samples + osf_nr_samples_cumulated + - osf_percent + osf_percent_cumulated, - osf_symb_name = 1 << 5, - osf_linenr_info = 1 << 6, - osf_short_linenr_info = 1 << 7,// w/o path name - osf_image_name = 1 << 8, - osf_short_image_name = 1 << 9, // w/o path name - /// only this field are showed in symbols samples details. + osf_none = 0, + osf_vma = 1 << 0, + /// this four field can be repeated on output for each counter. + osf_nr_samples = 1 << 1, + osf_nr_samples_cumulated = 1 << 2, + osf_percent = 1 << 3, + osf_percent_cumulated = 1 << 4, + + osf_symb_name = 1 << 5, + osf_linenr_info = 1 << 6, + osf_short_linenr_info = 1 << 7,// w/o path name + osf_image_name = 1 << 8, + osf_short_image_name = 1 << 9, // w/o path name osf_details = 1 << 10, // for oprofpp -L / -s - /// only this field are showed in symbols samples details. - osf_details_mask = osf_nr_samples + osf_nr_samples_cumulated + - osf_percent + osf_percent_cumulated + - osf_vma + osf_linenr_info + osf_short_linenr_info, // special format modifier: output all field selected separated by a // single space. This is intended to run post profile tools as // front-end of other tools which treat samples information. - osf_header = 1 << 11 + osf_header = 1 << 11, + + /// don't treat percent for details as relative to symbol but relative + /// to the total nr of samples + osf_percent_details = 1 << 12, + osf_percent_cumulated_details = 1 << 13, + + /// used internally + osf_repeat_mask = osf_nr_samples + osf_nr_samples_cumulated + + osf_percent + osf_percent_cumulated + + osf_percent_details + osf_percent_cumulated_details, + /// only this field are showed in symbols samples details. + osf_details_mask = osf_nr_samples + osf_nr_samples_cumulated + + osf_percent + osf_percent_cumulated + + osf_vma + osf_linenr_info + osf_short_linenr_info + + osf_percent_details + osf_percent_cumulated_details }; #endif // OUTSYMBFLAG_H |