$ZAM_PROFILE_ALL set tells ZAM to profile function bodies even if not executed

This commit is contained in:
Vern Paxson 2024-04-08 17:32:13 -04:00 committed by Tim Wojtulewicz
parent c11c2830b1
commit b3dacce3e1

View file

@ -82,6 +82,7 @@ void estimate_ZAM_profiling_overhead() {
#ifdef ENABLE_ZAM_PROFILE
static std::vector<const ZAMLocInfo*> caller_locs;
static bool profile_all = getenv("ZAM_PROFILE_ALL") != nullptr;
#define DO_ZAM_PROFILE \
if ( do_profile ) { \
@ -117,6 +118,8 @@ static std::vector<const ZAMLocInfo*> caller_locs;
#define ZAM_PROFILE_PRE_CALL
#define ZAM_PROFILE_POST_CALL
static bool profile_all = false;
#endif
using std::vector;
@ -144,7 +147,7 @@ void report_ZOP_profile() {
}
for ( int i = 1; i <= OP_NOP; ++i )
if ( ZOP_count[i] > 0 ) {
if ( ZOP_count[i] > 0 || profile_all ) {
auto CPU = std::max(ZOP_CPU[i] - ZOP_count[i] * CPU_prof_overhead, 0.0);
fprintf(analysis_options.profile_file, "%s\t%d\t%.06f\n", ZOP_name(ZOp(i)), ZOP_count[i], CPU);
}
@ -465,7 +468,8 @@ void ZBody::ReportExecutionProfile(ProfMap& pm) {
if ( dpv[0].num_samples == 0 && prof_vecs.empty() ) {
fprintf(analysis_options.profile_file, "%s did not execute\n", func_name.c_str());
return;
if ( ! profile_all )
return;
}
int total_samples = ncall + ninst;
@ -477,7 +481,7 @@ void ZBody::ReportExecutionProfile(ProfMap& pm) {
fprintf(analysis_options.profile_file, "%s CPU time %.06f, %" PRIu64 " memory, %d calls, %d sampled instructions\n",
func_name.c_str(), adj_CPU_time, tot_mem, ncall, ninst);
if ( dpv[0].num_samples != 0 )
if ( dpv[0].num_samples != 0 || profile_all )
ReportProfile(pm, dpv, "", {});
for ( auto& pv : prof_vecs ) {