From: Philippe E. <ph...@us...> - 2003-05-08 00:30:44
|
Update of /cvsroot/oprofile/oprofile/pp In directory sc8-pr-cvs1:/tmp/cvs-serv8518/pp Modified Files: Tag: pp-interface-branch opannotate.cpp opgprof.cpp opreport.cpp Log Message: when possible cumulate samples into a profile_t first before cumulating them in a profile_container. See mail list about improvment regarsd, Phil Index: opannotate.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/Attic/opannotate.cpp,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -d -r1.1.2.10 -r1.1.2.11 --- opannotate.cpp 7 May 2003 06:09:47 -0000 1.1.2.10 +++ opannotate.cpp 8 May 2003 00:30:41 -0000 1.1.2.11 @@ -68,17 +68,25 @@ pair<image_set::const_iterator, image_set::const_iterator> p_it = images.equal_range(it->first); + if (p_it.first == p_it.second) + continue; + op_bfd abfd(p_it.first->first, symbol_filter); + profile_t profile; - for (it = p_it.first; it != p_it.second; ++it) { - string app_name = it->second.image; - if (merge_lib) { - app_name = it->first; - } + string app_name = p_it.first->second.image; + if (merge_lib) { + app_name = p_it.first->first; + } - add_samples(samples, it->second.sample_filename, - abfd, app_name); + for (it = p_it.first; it != p_it.second; ++it) { + profile.add_sample_file(it->second.sample_filename, + abfd.get_start_offset()); } + + check_mtime(abfd.get_filename(), profile.get_header()); + + samples.add(profile, abfd, app_name); } return images; @@ -92,7 +100,8 @@ // seems like a bit of a hack. Abstract out the code // that opens the sample file and then get the header // from that directly, surely ? - profile_t profile(file_set.begin()->sample_filename, 0); + profile_t profile; + profile.add_sample_file(file_set.begin()->sample_filename, 0); header.reset(new opd_header(profile.get_header())); } } Index: opgprof.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/Attic/opgprof.cpp,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -d -r1.1.2.13 -r1.1.2.14 --- opgprof.cpp 7 May 2003 03:20:44 -0000 1.1.2.13 +++ opgprof.cpp 8 May 2003 00:30:41 -0000 1.1.2.14 @@ -12,6 +12,8 @@ #include <iostream> #include <cstdio> +#include "op_header.h" +#include "profile.h" #include "op_libiberty.h" #include "op_fileio.h" #include "string_filter.h" @@ -184,10 +186,21 @@ pair<image_set::const_iterator, image_set::const_iterator> p_it = images.equal_range(it->first); + if (p_it.first == p_it.second) + continue; + + string app_name = p_it.first->first; + + profile_t profile; + for (it = p_it.first; it != p_it.second; ++it) { - add_samples(samples, it->second.sample_filename, - abfd, it->first); + profile.add_sample_file(it->second.sample_filename, + abfd.get_start_offset()); } + + check_mtime(abfd.get_filename(), profile.get_header()); + + samples.add(profile, abfd, app_name); } return images.begin()->first; Index: opreport.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/pp/Attic/opreport.cpp,v retrieving revision 1.1.2.25 retrieving revision 1.1.2.26 diff -u -d -r1.1.2.25 -r1.1.2.26 --- opreport.cpp 7 May 2003 03:20:44 -0000 1.1.2.25 +++ opreport.cpp 8 May 2003 00:30:41 -0000 1.1.2.26 @@ -84,7 +84,9 @@ sub_count.image_name = it->image; sub_count.lib_image = it->lib_image; - profile_t samples(it->sample_filename, 0); + + profile_t samples; + samples.add_sample_file(it->sample_filename, 0); // THere's another FIXME on this elsewhere. Note // that the use of profile_t for this means we // pass in an offset of "0" instead of the real @@ -120,7 +122,8 @@ if (files.nr_set()) { partition_files::filename_set const & file_set = files.set(0); // See FIXME in opannotate.cpp for similar code - profile_t profile(file_set.begin()->sample_filename, 0); + profile_t profile; + profile.add_sample_file(file_set.begin()->sample_filename, 0); output_header(cout, profile.get_header()); } } @@ -209,16 +212,42 @@ pair<image_set::const_iterator, image_set::const_iterator> p_it = images.equal_range(it->first); + if (p_it.first == p_it.second) + continue; + op_bfd abfd(p_it.first->first, options::symbol_filter); - for (it = p_it.first; it != p_it.second; ++it) { - string app_name = it->second.image; - if (options::merge_by.merge_lib) { - app_name = it->first; + // we can optimize by cumulating samples to this binary in + // a profile_t only if we merge by lib since for non merging + // case application name change and must be recorded + if (options::merge_by.merge_lib) { + string app_name = p_it.first->first; + + profile_t profile; + + for (it = p_it.first; it != p_it.second; ++it) { + profile.add_sample_file( + it->second.sample_filename, + abfd.get_start_offset()); } - add_samples(samples, it->second.sample_filename, - abfd, app_name); + check_mtime(abfd.get_filename(), profile.get_header()); + + samples.add(profile, abfd, app_name); + } else { + for (it = p_it.first; it != p_it.second; ++it) { + string app_name = it->second.image; + + profile_t profile; + profile.add_sample_file( + it->second.sample_filename, + abfd.get_start_offset()); + + check_mtime(abfd.get_filename(), + profile.get_header()); + + samples.add(profile, abfd, app_name); + } } } |