diff options
Diffstat (limited to 'rts/Profiling.c')
-rw-r--r-- | rts/Profiling.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/rts/Profiling.c b/rts/Profiling.c index b0019a48fc..0dc1e26f80 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -118,6 +118,7 @@ static CostCentreStack * isInIndexTable ( IndexTable *, CostCentre * ); static IndexTable * addToIndexTable ( IndexTable *, CostCentreStack *, CostCentre *, unsigned int ); static void ccsSetSelected ( CostCentreStack *ccs ); +static void aggregateCCCosts( CostCentreStack *ccs ); static void initTimeProfiling ( void ); static void initProfilingLogFile ( void ); @@ -694,10 +695,16 @@ reportCCSProfiling( void ) if (RtsFlags.CcFlags.doCostCentres == 0) return; ProfilerTotals totals = countTickss(CCS_MAIN); + aggregateCCCosts(CCS_MAIN); inheritCosts(CCS_MAIN); CostCentreStack *stack = pruneCCSTree(CCS_MAIN); sortCCSTree(stack); - writeCCSReport(prof_file, stack, totals); + + if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_JSON) { + writeCCSReportJson(prof_file, stack, totals); + } else { + writeCCSReport(prof_file, stack, totals); + } } /* ----------------------------------------------------------------------------- @@ -752,6 +759,21 @@ inheritCosts(CostCentreStack *ccs) return; } +static void +aggregateCCCosts( CostCentreStack *ccs ) +{ + IndexTable *i; + + ccs->cc->mem_alloc += ccs->mem_alloc; + ccs->cc->time_ticks += ccs->time_ticks; + + for (i = ccs->indexTable; i != 0; i = i->next) { + if (!i->back_edge) { + aggregateCCCosts(i->ccs); + } + } +} + // // Prune CCSs with zero entries, zero ticks or zero allocation from // the tree, unless COST_CENTRES_ALL is on. |